]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Form/Type/NewUserType.php
CS
[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\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 'invalid_message' => 'The password fields must match',
24 'first_options' => array('label' => 'Password'),
25 'second_options' => array('label' => 'Repeat new password'),
26 'constraints' => array(
27 new Constraints\Length(array(
28 'min' => 8,
29 'minMessage' => 'Password should by at least 8 chars long',
30 )),
31 new Constraints\NotBlank(),
32 ),
33 ))
34 ->add('email', EmailType::class)
35 ->add('save', SubmitType::class)
36 ;
37 }
38
39 public function configureOptions(OptionsResolver $resolver)
40 {
41 $resolver->setDefaults(array(
42 'data_class' => 'Wallabag\UserBundle\Entity\User',
43 ));
44 }
45
46 public function getBlockPrefix()
47 {
48 return 'new_user';
49 }
50 }