]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | namespace Wallabag\CoreBundle\Form\Type; | |
4 | ||
5 | use Symfony\Component\Form\AbstractType; | |
6 | use Symfony\Component\Form\Extension\Core\Type\EmailType; | |
7 | use Symfony\Component\Form\Extension\Core\Type\PasswordType; | |
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; | |
11 | use Symfony\Component\Form\FormBuilderInterface; | |
12 | use Symfony\Component\OptionsResolver\OptionsResolver; | |
13 | use Symfony\Component\Validator\Constraints; | |
14 | ||
15 | class NewUserType extends AbstractType | |
16 | { | |
17 | public function buildForm(FormBuilderInterface $builder, array $options) | |
18 | { | |
19 | $builder | |
20 | ->add('username', TextType::class, array('required' => true)) | |
21 | ->add('plainPassword', RepeatedType::class, array( | |
22 | 'type' => PasswordType::class, | |
23 | 'constraints' => array( | |
24 | new Constraints\Length(array( | |
25 | 'min' => 8, | |
26 | 'minMessage' => 'Password should by at least 8 chars long', | |
27 | )), | |
28 | new Constraints\NotBlank(), | |
29 | ), | |
30 | )) | |
31 | ->add('email', EmailType::class) | |
32 | ->add('save', SubmitType::class) | |
33 | ; | |
34 | } | |
35 | ||
36 | public function configureOptions(OptionsResolver $resolver) | |
37 | { | |
38 | $resolver->setDefaults(array( | |
39 | 'data_class' => 'Wallabag\UserBundle\Entity\User', | |
40 | )); | |
41 | } | |
42 | ||
43 | public function getBlockPrefix() | |
44 | { | |
45 | return 'new_user'; | |
46 | } | |
47 | } |