-
Notifications
You must be signed in to change notification settings - Fork 106
/
RegistrationFormType.php
114 lines (106 loc) 路 3.54 KB
/
RegistrationFormType.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Enterprise License (PEL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PEL
*/
declare(strict_types=1);
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Enterprise License (PEL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PEL
*/
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\PasswordHasher\PasswordHasherInterface;
class RegistrationFormType extends AbstractType
{
/**
* @inheritDoc
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('email', EmailType::class, [
'label' => 'general.email',
'attr' => [
'maxlength' => 190
],
'required' => true
])
->add('firstname', TextType::class, [
'label' => 'general.firstname',
'attr' => [
'maxlength' => 190
],
'required' => true
])
->add('lastname', TextType::class, [
'label' => 'general.lastname',
'attr' => [
'maxlength' => 190
],
'required' => true
]);
if (!$options['hidePassword']) {
$builder->add('password', PasswordType::class, [
'label' => 'general.password',
'attr' => [
'maxlength' => PasswordHasherInterface::MAX_PASSWORD_LENGTH
]
]);
}
$builder
->add('newsletter', CheckboxType::class, [
'label' => 'general.newsletter',
'required' => false,
'label_attr' => [
'class' => 'checkbox-custom'
]
])
->add('profiling', CheckboxType::class, [
'label' => 'general.profiling',
'required' => false,
'label_attr' => [
'class' => 'checkbox-custom'
]
]);
$builder
->add('oAuthKey', HiddenType::class)
->add('_submit', SubmitType::class, [
'label' => 'Register',
'attr' => [
'class' => 'btn btn-lg btn-block btn-success'
]
]);
}
/**
* @inheritDoc
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefined('hidePassword');
}
}