]>
Commit | Line | Data |
---|---|---|
152fcccd JB |
1 | <?php |
2 | ||
3 | namespace Wallabag\UserBundle\Form; | |
4 | ||
6a50b4cc | 5 | use Symfony\Bridge\Doctrine\Form\Type\EntityType; |
152fcccd JB |
6 | use Symfony\Component\Form\AbstractType; |
7 | use Symfony\Component\Form\FormBuilderInterface; | |
8 | use Symfony\Component\OptionsResolver\OptionsResolver; | |
9 | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |
10 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |
11 | use Symfony\Component\Form\Extension\Core\Type\TextType; | |
12 | use Symfony\Component\Form\Extension\Core\Type\EmailType; | |
13 | ||
14 | class UserType extends AbstractType | |
15 | { | |
16 | /** | |
17 | * @param FormBuilderInterface $builder | |
18 | * @param array $options | |
19 | */ | |
20 | public function buildForm(FormBuilderInterface $builder, array $options) | |
21 | { | |
22 | $builder | |
23 | ->add('name', TextType::class, [ | |
24 | 'required' => false, | |
25 | 'label' => 'user.form.name_label', | |
26 | ]) | |
27 | ->add('username', TextType::class, [ | |
28 | 'required' => true, | |
29 | 'label' => 'user.form.username_label', | |
30 | ]) | |
6a50b4cc NL |
31 | ->add('groups', EntityType::class, array( |
32 | 'class' => 'WallabagGroupBundle:Group', | |
33 | 'choice_label' => 'name', | |
34 | 'multiple' => true, | |
35 | 'expanded' => true, | |
36 | )) | |
152fcccd JB |
37 | ->add('email', EmailType::class, [ |
38 | 'required' => true, | |
39 | 'label' => 'user.form.email_label', | |
40 | ]) | |
41 | ->add('enabled', CheckboxType::class, [ | |
42 | 'required' => false, | |
43 | 'label' => 'user.form.enabled_label', | |
44 | ]) | |
152fcccd JB |
45 | ->add('twoFactorAuthentication', CheckboxType::class, [ |
46 | 'required' => false, | |
47 | 'label' => 'user.form.twofactor_label', | |
48 | ]) | |
49 | ->add('save', SubmitType::class, [ | |
50 | 'label' => 'user.form.save', | |
51 | ]) | |
52 | ; | |
53 | } | |
54 | ||
55 | /** | |
56 | * @param OptionsResolver $resolver | |
57 | */ | |
58 | public function configureOptions(OptionsResolver $resolver) | |
59 | { | |
60 | $resolver->setDefaults(array( | |
61 | 'data_class' => 'Wallabag\UserBundle\Entity\User', | |
62 | )); | |
63 | } | |
64 | } |