1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Form\Type; |
4
|
|
|
|
5
|
|
|
use App\Entity\User; |
6
|
|
|
use Symfony\Component\Form\AbstractType; |
7
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
8
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
9
|
|
|
use Symfony\Component\Form\Extension\Core\Type\EmailType; |
10
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
11
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
12
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @author Philip Washington Sorst <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class UserEditType extends AbstractType |
18
|
|
|
{ |
19
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options) |
20
|
|
|
{ |
21
|
|
|
$builder |
22
|
|
|
->add('username', TextType::class, ['required' => true]) |
23
|
|
|
->add('realName', TextType::class, ['required' => true]) |
24
|
|
|
->add('email', EmailType::class, ['required' => true]) |
25
|
|
|
->add('plainPassword', TextType::class, ['label' => 'Password', 'required' => false]) |
26
|
|
|
->add( |
27
|
|
|
'roles', |
28
|
|
|
ChoiceType::class, |
29
|
|
|
[ |
30
|
|
|
'expanded' => true, |
31
|
|
|
'multiple' => true, |
32
|
|
|
'choices' => [ |
33
|
|
|
'Admin' => 'ROLE_ADMIN', |
34
|
|
|
'User' => 'ROLE_USER', |
35
|
|
|
] |
36
|
|
|
] |
37
|
|
|
) |
38
|
|
|
->add('githubId', TextType::class, ['required' => false]) |
39
|
|
|
->add('googleId', TextType::class, ['required' => false]) |
40
|
|
|
->add('facebookId', TextType::class, ['required' => false]) |
41
|
|
|
->add('enabled', CheckboxType::class, ['required' => false]); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function configureOptions(OptionsResolver $resolver) |
45
|
|
|
{ |
46
|
|
|
$resolver->setDefaults( |
47
|
|
|
[ |
48
|
|
|
'data_class' => User::class |
49
|
|
|
] |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
} |
54
|
|
|
|