]>
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\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('plainPassword', 'repeated', array( | |
17 | 'type' => 'password', | |
18 | 'constraints' => array( | |
19 | new Constraints\Length(array( | |
20 | 'min' => 8, | |
21 | 'minMessage' => 'Password should by at least 8 chars long', | |
22 | )), | |
23 | new Constraints\NotBlank(), | |
24 | ), | |
25 | )) | |
26 | ->add('email', 'email') | |
27 | ->add('save', 'submit') | |
28 | ; | |
29 | } | |
30 | ||
31 | public function configureOptions(OptionsResolver $resolver) | |
32 | { | |
33 | $resolver->setDefaults(array( | |
34 | 'data_class' => 'Wallabag\UserBundle\Entity\User', | |
35 | )); | |
36 | } | |
37 | ||
38 | public function getName() | |
39 | { | |
40 | return 'new_user'; | |
41 | } | |
42 | } |