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