]>
Commit | Line | Data |
---|---|---|
e4977b8a | 1 | <?php |
4346a860 | 2 | |
e4977b8a J |
3 | namespace Wallabag\CoreBundle\Form\Type; |
4 | ||
5 | use Symfony\Component\Form\AbstractType; | |
619cc453 | 6 | use Symfony\Component\Form\Extension\Core\Type\EmailType; |
5c895a7f | 7 | use Symfony\Component\Form\Extension\Core\Type\PasswordType; |
619cc453 JB |
8 | use Symfony\Component\Form\Extension\Core\Type\RepeatedType; |
9 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |
10 | use Symfony\Component\Form\Extension\Core\Type\TextType; | |
e4977b8a | 11 | use Symfony\Component\Form\FormBuilderInterface; |
75e9d1df | 12 | use Symfony\Component\OptionsResolver\OptionsResolver; |
e4977b8a J |
13 | use Symfony\Component\Validator\Constraints; |
14 | ||
15 | class NewUserType extends AbstractType | |
16 | { | |
17 | public function buildForm(FormBuilderInterface $builder, array $options) | |
18 | { | |
19 | $builder | |
0d42217e JB |
20 | ->add('username', TextType::class, array( |
21 | 'required' => true, | |
22 | 'label' => 'config.form_new_user.username_label', | |
23 | )) | |
619cc453 | 24 | ->add('plainPassword', RepeatedType::class, array( |
5c895a7f | 25 | 'type' => PasswordType::class, |
0d42217e JB |
26 | 'invalid_message' => 'validator.password_must_match', |
27 | 'first_options' => array('label' => 'config.form_new_user.password_label'), | |
28 | 'second_options' => array('label' => 'config.form_new_user.repeat_new_password_label'), | |
e4977b8a J |
29 | 'constraints' => array( |
30 | new Constraints\Length(array( | |
31 | 'min' => 8, | |
0d42217e | 32 | 'minMessage' => 'validator.password_too_short', |
e4977b8a J |
33 | )), |
34 | new Constraints\NotBlank(), | |
35 | ), | |
0d42217e JB |
36 | 'label' => 'config.form_new_user.plain_password_label', |
37 | )) | |
38 | ->add('email', EmailType::class, array( | |
39 | 'label' => 'config.form_new_user.email_label', | |
40 | )) | |
41 | ->add('save', SubmitType::class, array( | |
42 | 'label' => 'config.form.save', | |
e4977b8a | 43 | )) |
e4977b8a J |
44 | ; |
45 | } | |
46 | ||
75e9d1df | 47 | public function configureOptions(OptionsResolver $resolver) |
e4977b8a J |
48 | { |
49 | $resolver->setDefaults(array( | |
1210dae1 | 50 | 'data_class' => 'Wallabag\UserBundle\Entity\User', |
e4977b8a J |
51 | )); |
52 | } | |
53 | ||
619cc453 | 54 | public function getBlockPrefix() |
e4977b8a J |
55 | { |
56 | return 'new_user'; | |
57 | } | |
58 | } |