]>
Commit | Line | Data |
---|---|---|
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\OptionsResolverInterface; | |
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') | |
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', 'text') | |
26 | ->add('save', 'submit') | |
27 | ; | |
28 | } | |
29 | ||
30 | public function setDefaultOptions(OptionsResolverInterface $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 | } |