1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Form\User; |
4
|
|
|
|
5
|
|
|
use AppBundle\Entity\S3\Image; |
6
|
|
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType; |
7
|
|
|
use Symfony\Component\Form\AbstractType; |
8
|
|
|
use Symfony\Component\Form\Extension\Core\Type\FileType; |
9
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
10
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
11
|
|
|
use Symfony\Component\Form\FormEvent; |
12
|
|
|
use Symfony\Component\Form\FormEvents; |
13
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
14
|
|
|
use Symfony\Component\Form\Extension\Core\Type\EmailType; |
15
|
|
|
use Symfony\Component\Form\Extension\Core\Type\RepeatedType; |
16
|
|
|
use Symfony\Component\Form\Extension\Core\Type\PasswordType; |
17
|
|
|
use AppBundle\Entity\User; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class UserType. |
21
|
|
|
|
22
|
|
|
*/ |
23
|
|
|
class EditType extends AbstractType |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @param FormBuilderInterface $builder |
27
|
|
|
* @param array $options |
28
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
29
|
|
|
* After add new field in UserType need create |
30
|
|
|
* offsetUnset() method from this field in Security controller |
31
|
|
|
*/ |
32
|
2 |
|
public function buildForm(FormBuilderInterface $builder, array $options) |
33
|
|
|
{ |
34
|
|
|
$builder |
35
|
2 |
|
->add('firstName', TextType::class, [ |
36
|
2 |
|
'attr' => [ |
37
|
|
|
'placeholder' => 'First Name', |
38
|
|
|
'class' => 'form-control', |
39
|
|
|
], |
40
|
|
|
'label' => false, |
41
|
|
|
]) |
42
|
2 |
|
->add('lastName', TextType::class, [ |
43
|
2 |
|
'attr' => [ |
44
|
|
|
'placeholder' => 'Last Name', |
45
|
|
|
'class' => 'form-control', |
46
|
|
|
], |
47
|
|
|
'label' => false, |
48
|
|
|
]) |
49
|
2 |
|
->add('email', EmailType::class, [ |
50
|
2 |
|
'attr' => [ |
51
|
|
|
'placeholder' => 'E-mail', |
52
|
|
|
'class' => 'form-control', |
53
|
|
|
], |
54
|
|
|
'label' => false, |
55
|
|
|
]) |
56
|
2 |
|
->add('plainPassword', RepeatedType::class, [ |
57
|
2 |
|
'type' => PasswordType::class, |
58
|
|
|
'first_options' => [ |
59
|
|
|
'attr' => [ |
60
|
|
|
'placeholder' => 'Password', |
61
|
|
|
'class' => 'form-control', |
62
|
|
|
], |
63
|
|
|
'label' => false, |
64
|
|
|
], |
65
|
|
|
'second_options' => [ |
66
|
|
|
'attr' => [ |
67
|
|
|
'placeholder' => 'Repeat password', |
68
|
|
|
'class' => 'form-control', |
69
|
|
|
], |
70
|
|
|
'label' => false, |
71
|
|
|
], |
72
|
|
|
'required' => false |
73
|
|
|
]); |
74
|
2 |
|
} |
75
|
|
|
|
76
|
2 |
|
public function configureOptions(OptionsResolver $resolver) |
77
|
|
|
{ |
78
|
2 |
|
$resolver->setDefaults([ |
79
|
2 |
|
'data_class' => User::class, |
80
|
|
|
'validation_groups' => ['registration', 'edit'], |
81
|
|
|
'attr' => ['novalidate' => 'novalidate'] |
82
|
|
|
]); |
83
|
2 |
|
} |
84
|
|
|
} |
85
|
|
|
|