]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/UserBundle/Form/UserType.php
Merge remote-tracking branch 'origin/master' into 2.4
[github/wallabag/wallabag.git] / src / Wallabag / UserBundle / Form / UserType.php
1 <?php
2
3 namespace Wallabag\UserBundle\Form;
4
5 use Symfony\Component\Form\AbstractType;
6 use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
7 use Symfony\Component\Form\Extension\Core\Type\EmailType;
8 use Symfony\Component\Form\Extension\Core\Type\SubmitType;
9 use Symfony\Component\Form\Extension\Core\Type\TextType;
10 use Symfony\Component\Form\FormBuilderInterface;
11 use Symfony\Component\OptionsResolver\OptionsResolver;
12
13 class UserType extends AbstractType
14 {
15 /**
16 * @param FormBuilderInterface $builder
17 * @param array $options
18 */
19 public function buildForm(FormBuilderInterface $builder, array $options)
20 {
21 $builder
22 ->add('name', TextType::class, [
23 'required' => false,
24 'label' => 'user.form.name_label',
25 ])
26 ->add('username', TextType::class, [
27 'required' => true,
28 'label' => 'user.form.username_label',
29 ])
30 ->add('email', EmailType::class, [
31 'required' => true,
32 'label' => 'user.form.email_label',
33 ])
34 ->add('enabled', CheckboxType::class, [
35 'required' => false,
36 'label' => 'user.form.enabled_label',
37 ])
38 ->add('emailTwoFactor', CheckboxType::class, [
39 'required' => false,
40 'label' => 'user.form.twofactor_email_label',
41 ])
42 ->add('googleTwoFactor', CheckboxType::class, [
43 'required' => false,
44 'label' => 'user.form.twofactor_google_label',
45 'mapped' => false,
46 ])
47 ->add('save', SubmitType::class, [
48 'label' => 'user.form.save',
49 ])
50 ;
51 }
52
53 /**
54 * @param OptionsResolver $resolver
55 */
56 public function configureOptions(OptionsResolver $resolver)
57 {
58 $resolver->setDefaults([
59 'data_class' => 'Wallabag\UserBundle\Entity\User',
60 ]);
61 }
62 }