]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | namespace Wallabag\CoreBundle\Form\Type; | |
4 | ||
5 | use Symfony\Component\Form\AbstractType; | |
6 | use Symfony\Component\Form\Extension\Core\Type\PasswordType; | |
7 | use Symfony\Component\Form\Extension\Core\Type\RepeatedType; | |
8 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |
9 | use Symfony\Component\Form\FormBuilderInterface; | |
10 | use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; | |
11 | use Symfony\Component\Validator\Constraints; | |
12 | ||
13 | class ChangePasswordType extends AbstractType | |
14 | { | |
15 | public function buildForm(FormBuilderInterface $builder, array $options) | |
16 | { | |
17 | $builder | |
18 | ->add('old_password', PasswordType::class, array( | |
19 | 'constraints' => new UserPassword(array('message' => 'validator.password_wrong_value')), | |
20 | 'label' => 'config.form_password.old_password_label', | |
21 | )) | |
22 | ->add('new_password', RepeatedType::class, array( | |
23 | 'type' => PasswordType::class, | |
24 | 'invalid_message' => 'validator.password_must_match', | |
25 | 'required' => true, | |
26 | 'first_options' => array('label' => 'config.form_password.new_password_label'), | |
27 | 'second_options' => array('label' => 'config.form_password.repeat_new_password_label'), | |
28 | 'constraints' => array( | |
29 | new Constraints\Length(array( | |
30 | 'min' => 8, | |
31 | 'minMessage' => 'validator.password_too_short', | |
32 | )), | |
33 | new Constraints\NotBlank(), | |
34 | ), | |
35 | 'label' => 'config.form_password.new_password_label', | |
36 | )) | |
37 | ->add('save', SubmitType::class, array( | |
38 | 'label' => 'config.form.save', | |
39 | )) | |
40 | ; | |
41 | } | |
42 | ||
43 | public function getBlockPrefix() | |
44 | { | |
45 | return 'change_passwd'; | |
46 | } | |
47 | } |