]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Form/Type/NewUserType.php
Merge pull request #1180 from wallabag/v2patch
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Form / Type / NewUserType.php
1 <?php
2 namespace Wallabag\CoreBundle\Form\Type;
3
4 use Symfony\Component\Form\AbstractType;
5 use Symfony\Component\Form\FormBuilderInterface;
6 use Symfony\Component\OptionsResolver\OptionsResolverInterface;
7 use Symfony\Component\Validator\Constraints;
8
9 class NewUserType extends AbstractType
10 {
11 public function buildForm(FormBuilderInterface $builder, array $options)
12 {
13 $builder
14 ->add('username', 'text', array('required' => true))
15 ->add('password', 'password', array(
16 'constraints' => array(
17 new Constraints\Length(array(
18 'min' => 8,
19 'minMessage' => 'Password should by at least 8 chars long',
20 )),
21 new Constraints\NotBlank(),
22 ),
23 ))
24 ->add('email', 'email')
25 ->add('save', 'submit')
26 ;
27 }
28
29 public function setDefaultOptions(OptionsResolverInterface $resolver)
30 {
31 $resolver->setDefaults(array(
32 'data_class' => 'Wallabag\CoreBundle\Entity\User',
33 ));
34 }
35
36 public function getName()
37 {
38 return 'new_user';
39 }
40 }