-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegistrationFormType.php
More file actions
72 lines (68 loc) · 2.02 KB
/
RegistrationFormType.php
File metadata and controls
72 lines (68 loc) · 2.02 KB
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
<?php
namespace SyncEngine\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\IsTrue;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use SyncEngine\Entity\User;
class RegistrationFormType extends AbstractType
{
public function buildForm( FormBuilderInterface $builder, array $options ): void
{
$builder
->add('email', TextType::class, [
'row_attr' => [
'class' => 'form-floating mb-3',
],
])
->add('name', TextType::class, [
'row_attr' => [
'class' => 'form-floating mb-3',
],
])
->add('plainPassword', PasswordType::class, [
'row_attr' => [
'class' => 'form-floating mb-3',
],
// instead of being set onto the object directly,
// this is read and encoded in the controller
'mapped' => false,
'attr' => ['autocomplete' => 'new-password'],
'constraints' => [
new NotBlank([
'message' => 'Please enter a password',
]),
new Length([
'min' => 6,
'minMessage' => 'Your password should be at least { limit } characters',
// max length allowed by Symfony for security reasons
'max' => 4096,
]),
],
])
->add('agreeTerms', CheckboxType::class, [
'row_attr' => [
'class' => 'form-floating mb-3',
],
'label' => '<a href="https://syncengine.io/license" target="_blank">I accept the license terms and conditions</a>',
'label_html' => true,
'mapped' => false,
'constraints' => [
new IsTrue([
'message' => 'You should agree to our license terms.',
]),
],
]);
}
public function configureOptions( OptionsResolver $resolver ): void
{
$resolver->setDefaults( [
'data_class' => User::class,
] );
}
}