]>
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' => 'Wrong value for your current password')), | |
20 | )) | |
21 | ->add('new_password', RepeatedType::class, array( | |
22 | 'type' => PasswordType::class, | |
23 | 'invalid_message' => 'The password fields must match.', | |
24 | 'required' => true, | |
25 | 'first_options' => array('label' => 'New password'), | |
26 | 'second_options' => array('label' => 'Repeat new password'), | |
27 | 'constraints' => array( | |
28 | new Constraints\Length(array( | |
29 | 'min' => 8, | |
30 | 'minMessage' => 'Password should by at least 8 chars long', | |
31 | )), | |
32 | new Constraints\NotBlank(), | |
33 | ), | |
34 | )) | |
35 | ->add('save', SubmitType::class) | |
36 | ; | |
37 | } | |
38 | ||
39 | public function getBlockPrefix() | |
40 | { | |
41 | return 'change_passwd'; | |
42 | } | |
43 | } |