]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Form/Type/NewUserType.php
Adding new user
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Form / Type / NewUserType.php
CommitLineData
e4977b8a
J
1<?php
2namespace Wallabag\CoreBundle\Form\Type;
3
4use Symfony\Component\Form\AbstractType;
5use Symfony\Component\Form\FormBuilderInterface;
6use Symfony\Component\OptionsResolver\OptionsResolverInterface;
7use Symfony\Component\Validator\Constraints;
8
9class NewUserType extends AbstractType
10{
11 public function buildForm(FormBuilderInterface $builder, array $options)
12 {
13 $builder
14 ->add('username', 'text')
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', 'text')
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}