wallabag/src/Form/Type/ChangePasswordType.php

49 lines
1.8 KiB
PHP
Raw Normal View History

2015-02-17 20:03:23 +00:00
<?php
2015-05-30 11:52:26 +00:00
2024-02-19 00:30:12 +00:00
namespace Wallabag\Form\Type;
2015-02-17 20:03:23 +00:00
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;
2015-02-17 20:03:23 +00:00
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
2022-08-28 14:59:43 +00:00
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
2015-02-17 20:03:23 +00:00
class ChangePasswordType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->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',
2015-02-17 20:03:23 +00:00
'required' => true,
'first_options' => ['label' => 'config.form_password.new_password_label'],
'second_options' => ['label' => 'config.form_password.repeat_new_password_label'],
'constraints' => [
2022-08-28 14:59:43 +00:00
new Length([
'min' => 8,
'minMessage' => 'validator.password_too_short',
]),
2022-08-28 14:59:43 +00:00
new NotBlank(),
],
'label' => 'config.form_password.new_password_label',
])
->add('save', SubmitType::class, [
'label' => 'config.form.save',
])
2015-02-17 20:03:23 +00:00
;
}
public function getBlockPrefix()
2015-02-17 20:03:23 +00:00
{
return 'change_passwd';
}
}