diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Form')
-rw-r--r-- | src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php b/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php new file mode 100644 index 00000000..8bf4ca1e --- /dev/null +++ b/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php | |||
@@ -0,0 +1,40 @@ | |||
1 | <?php | ||
2 | namespace Wallabag\CoreBundle\Form\Type; | ||
3 | |||
4 | use Symfony\Component\Form\AbstractType; | ||
5 | use Symfony\Component\Form\FormBuilderInterface; | ||
6 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
7 | use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; | ||
8 | use Symfony\Component\Validator\Constraints; | ||
9 | |||
10 | class ChangePasswordType extends AbstractType | ||
11 | { | ||
12 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
13 | { | ||
14 | $builder | ||
15 | ->add('old_password', 'password', array( | ||
16 | 'constraints' => new UserPassword(array('message' => 'Wrong value for your current password')), | ||
17 | )) | ||
18 | ->add('new_password', 'repeated', array( | ||
19 | 'type' => 'password', | ||
20 | 'invalid_message' => 'The password fields must match.', | ||
21 | 'required' => true, | ||
22 | 'first_options' => array('label' => 'New password'), | ||
23 | 'second_options' => array('label' => 'Repeat new password'), | ||
24 | 'constraints' => array( | ||
25 | new Constraints\Length(array( | ||
26 | 'min' => 6, | ||
27 | 'minMessage' => 'Password should by at least 6 chars long' | ||
28 | )), | ||
29 | new Constraints\NotBlank() | ||
30 | ) | ||
31 | )) | ||
32 | ->add('save', 'submit') | ||
33 | ; | ||
34 | } | ||
35 | |||
36 | public function getName() | ||
37 | { | ||
38 | return 'change_passwd'; | ||
39 | } | ||
40 | } | ||