Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 52 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
EditProfileFormType | |
0.00% |
0 / 52 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
buildForm | |
0.00% |
0 / 46 |
|
0.00% |
0 / 1 |
2 | |||
configureOptions | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace App\Form; |
4 | |
5 | use App\Entity\User; |
6 | use Symfony\Component\Form\AbstractType; |
7 | use Symfony\Component\Form\Extension\Core\Type\EmailType; |
8 | use Symfony\Component\Form\Extension\Core\Type\PasswordType; |
9 | use Symfony\Component\Form\Extension\Core\Type\RepeatedType; |
10 | use Symfony\Component\Form\FormBuilderInterface; |
11 | use Symfony\Component\OptionsResolver\OptionsResolver; |
12 | use Symfony\Component\Validator\Constraints\Length; |
13 | use Symfony\UX\Cropperjs\Form\CropperType; |
14 | use Symfony\UX\Dropzone\Form\DropzoneType; |
15 | |
16 | class EditProfileFormType extends AbstractType |
17 | { |
18 | public function buildForm(FormBuilderInterface $builder, array $options): void |
19 | { |
20 | $builder |
21 | ->add(child: 'username', options: [ |
22 | 'attr' => [ |
23 | 'autocomplete' => 'nickname' |
24 | ] |
25 | ]) |
26 | ->add(child: 'firstName', options: [ |
27 | 'required' => false, |
28 | 'attr' => [ |
29 | 'autocomplete' => 'given-name' |
30 | ] |
31 | ]) |
32 | ->add(child: 'lastName', options: [ |
33 | 'required' => false, |
34 | 'attr' => [ |
35 | 'autocomplete' => 'family-name' |
36 | ] |
37 | |
38 | ]) |
39 | ->add(child: 'email', type: EmailType::class, options: [ |
40 | 'attr' => [ |
41 | 'autocomplete' => 'email' |
42 | ] |
43 | ]) |
44 | /* |
45 | ->add(child: 'avatarName', type: DropzoneType::class, options: [ |
46 | 'mapped' => false, |
47 | 'required' => false, |
48 | 'attr' => [ |
49 | 'data-controller' => 'upload-avatar', |
50 | ] |
51 | ]) |
52 | */ |
53 | ->add(child: 'newPassword', type: RepeatedType::class, options: [ |
54 | 'type' => PasswordType::class, |
55 | 'mapped' => false, |
56 | 'invalid_message' => 'The password fields must match.', |
57 | 'required' => false, |
58 | 'first_options' => ['label' => 'Password'], |
59 | 'second_options' => ['label' => 'Repeat Password (only needed if you want to update the password)'], |
60 | 'constraints' => [new Length(exactly: ['min' => 6])], |
61 | 'options' => [ |
62 | 'attr' => [ |
63 | 'autocomplete' => 'new-password' |
64 | ] |
65 | ] |
66 | ]); |
67 | } |
68 | |
69 | public function configureOptions(OptionsResolver $resolver): void |
70 | { |
71 | $resolver->setDefaults(defaults: [ |
72 | 'data_class' => User::class, |
73 | 'csrf_protection' => true, |
74 | 'csrf_field_name' => '_csrf_token', |
75 | 'csrf_token_id' => 'authenticate' |
76 | ]); |
77 | } |
78 | } |