|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Form; |
|
4
|
|
|
|
|
5
|
|
|
use App\Security\PasswordStrengthHelper; |
|
6
|
|
|
use Symfony\Component\Form\AbstractType; |
|
7
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
|
8
|
|
|
use Symfony\Component\Form\Extension\Core\Type\EmailType; |
|
9
|
|
|
use Symfony\Component\Form\Extension\Core\Type\PasswordType; |
|
10
|
|
|
use Symfony\Component\Form\Extension\Core\Type\RepeatedType; |
|
11
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
|
12
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
|
13
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
14
|
|
|
use Symfony\Component\Validator\Constraints\IsTrue; |
|
15
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface; |
|
16
|
|
|
|
|
17
|
|
|
class UserProfileCompleteType extends AbstractType { |
|
18
|
|
|
|
|
19
|
|
|
public function __construct(private PasswordStrengthHelper $passwordStrengthHelper, private TranslatorInterface $translator) |
|
20
|
|
|
{ |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function configureOptions(OptionsResolver $resolver) { |
|
24
|
|
|
parent::configureOptions($resolver); |
|
25
|
|
|
|
|
26
|
|
|
$resolver->setRequired('username_suffix'); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options) { |
|
30
|
|
|
$builder |
|
31
|
|
|
->add('username', TextSuffixType::class, [ |
|
32
|
|
|
'label' => 'label.username', |
|
33
|
|
|
'suffix' => $options['username_suffix'] |
|
34
|
|
|
]); |
|
35
|
|
|
|
|
36
|
|
|
$builder |
|
37
|
|
|
->add('password', RepeatedType::class, [ |
|
38
|
|
|
'type' => PasswordType::class, |
|
39
|
|
|
'mapped' => false, |
|
40
|
|
|
'invalid_message' => 'The password fields must match.', |
|
41
|
|
|
'options' => [ |
|
42
|
|
|
'attr' => [ |
|
43
|
|
|
'class' => 'password-field', |
|
44
|
|
|
'autocomplete' => 'new-password' |
|
45
|
|
|
], |
|
46
|
|
|
], |
|
47
|
|
|
'constraints' => $this->passwordStrengthHelper->getConstraints(), |
|
48
|
|
|
'first_options' => [ |
|
49
|
|
|
'label' => 'label.password', |
|
50
|
|
|
'help' => $this->translator->trans('password.requirements', [], 'security') |
|
51
|
|
|
], |
|
52
|
|
|
'second_options' => ['label' => 'label.repeat_password'] |
|
53
|
|
|
]) |
|
54
|
|
|
->add('agreePrivacyPolicy', CheckboxType::class, [ |
|
55
|
|
|
'required' => true, |
|
56
|
|
|
'label' => 'privacy_policy.accept', |
|
57
|
|
|
'constraints' => [ |
|
58
|
|
|
new IsTrue() |
|
59
|
|
|
], |
|
60
|
|
|
'mapped' => false, |
|
61
|
|
|
'label_attr' => [ |
|
62
|
|
|
'class' => 'checkbox-custom' |
|
63
|
|
|
] |
|
64
|
|
|
]) |
|
65
|
|
|
->add('firstname', TextType::class, [ |
|
66
|
|
|
'label' => 'label.firstname', |
|
67
|
|
|
'required' => false, |
|
68
|
|
|
'help' => 'help.voluntary' |
|
69
|
|
|
]) |
|
70
|
|
|
->add('lastname', TextType::class, [ |
|
71
|
|
|
'label' => 'label.lastname', |
|
72
|
|
|
'required' => false, |
|
73
|
|
|
'help' => 'help.voluntary' |
|
74
|
|
|
]) |
|
75
|
|
|
->add('email', RepeatedType::class, [ |
|
76
|
|
|
'type' => EmailType::class, |
|
77
|
|
|
'required' => false, |
|
78
|
|
|
'invalid_message' => $this->translator->trans('register.email.not_match', [], 'security'), |
|
79
|
|
|
'first_options' => [ |
|
80
|
|
|
'label' => 'label.email', |
|
81
|
|
|
'help' => $this->translator->trans('register.complete.email_help', [], 'security') |
|
82
|
|
|
], |
|
83
|
|
|
'second_options' => [ |
|
84
|
|
|
'label' => 'label.repeat_email' |
|
85
|
|
|
] |
|
86
|
|
|
]); |
|
87
|
|
|
} |
|
88
|
|
|
} |