wallabag/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php

44 lines
1.6 KiB
PHP
Raw Normal View History

2015-02-17 20:03:23 +00:00
<?php
2015-05-30 11:52:26 +00:00
2015-02-17 20:03:23 +00:00
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;
2015-02-17 20:03:23 +00:00
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
use Symfony\Component\Validator\Constraints;
class ChangePasswordType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('old_password', PasswordType::class, array(
2015-02-17 20:03:23 +00:00
'constraints' => new UserPassword(array('message' => 'Wrong value for your current password')),
))
->add('new_password', RepeatedType::class, array(
'type' => PasswordType::class,
2015-02-17 20:03:23 +00:00
'invalid_message' => 'The password fields must match.',
'required' => true,
'first_options' => array('label' => 'New password'),
2015-02-17 20:03:23 +00:00
'second_options' => array('label' => 'Repeat new password'),
'constraints' => array(
new Constraints\Length(array(
'min' => 8,
2015-02-22 08:30:25 +00:00
'minMessage' => 'Password should by at least 8 chars long',
2015-02-17 20:03:23 +00:00
)),
new Constraints\NotBlank(),
),
2015-02-17 20:03:23 +00:00
))
->add('save', SubmitType::class)
2015-02-17 20:03:23 +00:00
;
}
public function getBlockPrefix()
2015-02-17 20:03:23 +00:00
{
return 'change_passwd';
}
}