X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FForm%2FType%2FChangePasswordType.php;h=81c4a6166708992524d22a4214d5a72ed04adf24;hb=f2e5fdc3666a2a6525b4202ab48df05efeebaf5c;hp=82e1954d1a871906c5220ff6a5bbf39edbf01e53;hpb=8ce32af61229eec8f4cc34b207273d47f60adc48;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php b/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php index 82e1954d..81c4a616 100644 --- a/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php +++ b/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php @@ -3,6 +3,9 @@ namespace Wallabag\CoreBundle\Form\Type; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\PasswordType; +use Symfony\Component\Form\Extension\Core\Type\RepeatedType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; use Symfony\Component\Validator\Constraints; @@ -12,28 +15,32 @@ class ChangePasswordType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('old_password', 'password', array( - 'constraints' => new UserPassword(array('message' => 'Wrong value for your current password')), - )) - ->add('new_password', 'repeated', array( - 'type' => 'password', - 'invalid_message' => 'The password fields must match.', + ->add('old_password', PasswordType::class, [ + 'constraints' => new UserPassword(['message' => 'validator.password_wrong_value']), + 'label' => 'config.form_password.old_password_label', + ]) + ->add('new_password', RepeatedType::class, [ + 'type' => PasswordType::class, + 'invalid_message' => 'validator.password_must_match', 'required' => true, - 'first_options' => array('label' => 'New password'), - 'second_options' => array('label' => 'Repeat new password'), - 'constraints' => array( - new Constraints\Length(array( + 'first_options' => ['label' => 'config.form_password.new_password_label'], + 'second_options' => ['label' => 'config.form_password.repeat_new_password_label'], + 'constraints' => [ + new Constraints\Length([ 'min' => 8, - 'minMessage' => 'Password should by at least 8 chars long', - )), + 'minMessage' => 'validator.password_too_short', + ]), new Constraints\NotBlank(), - ), - )) - ->add('save', 'submit') + ], + 'label' => 'config.form_password.new_password_label', + ]) + ->add('save', SubmitType::class, [ + 'label' => 'config.form.save', + ]) ; } - public function getName() + public function getBlockPrefix() { return 'change_passwd'; }