aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Form/Type/NewUserType.php')
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/NewUserType.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Form/Type/NewUserType.php b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
new file mode 100644
index 00000000..313a9aae
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
@@ -0,0 +1,40 @@
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}