]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Form/Type/NewUserType.php
e6fff976647afea3e41c6ed59ffb8d41134d6bb4
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Form / Type / NewUserType.php
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\RepeatedType;
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 use Symfony\Component\Validator\Constraints;
13
14 class NewUserType extends AbstractType
15 {
16 public function buildForm(FormBuilderInterface $builder, array $options)
17 {
18 $builder
19 ->add('username', TextType::class, array('required' => true))
20 ->add('plainPassword', RepeatedType::class, array(
21 'type' => 'password',
22 'constraints' => array(
23 new Constraints\Length(array(
24 'min' => 8,
25 'minMessage' => 'Password should by at least 8 chars long',
26 )),
27 new Constraints\NotBlank(),
28 ),
29 ))
30 ->add('email', EmailType::class)
31 ->add('save', SubmitType::class)
32 ;
33 }
34
35 public function configureOptions(OptionsResolver $resolver)
36 {
37 $resolver->setDefaults(array(
38 'data_class' => 'Wallabag\UserBundle\Entity\User',
39 ));
40 }
41
42 public function getBlockPrefix()
43 {
44 return 'new_user';
45 }
46 }