php - Equal Fields validation in Symfony 2 -



php - Equal Fields validation in Symfony 2 -

i'm trying implement alter password functionality in symfony 2 project. have entity user validation rules in validation.yml file. in user entity have field "password" validation constraints in validation.yml. created form 2 field 'password' , 'confirmpasswod'. want utilize entity validation constraints 'password' field , check equality between 'passwod' , 'confirmpassword' fields. in contronller write

$form = $this->createform(new symfonyform\changepasswordtype(), new entity\user()); if ($form->isvalid()) {..............}

in 'user' entity don't have 'confirmpasswod' field. error:

neither property "confirmpassword" nor method "getconfirmpassword()" nor method "isconfirmpassword()" exists in class

is there way utilize entity-based form validation form fields , not entity-based validation other? in advance.

in symfonyform\changepasswordtype can utilize this:

$builder->add('password', 'repeated', array( 'type' => 'password', 'first_name' => 'password', 'second_name' => 'password confirmation', 'invalid_message' => 'passwords not same', ));

since symfony 2.1 can configure options avoid broken element name (as mentioned in comment)

$builder->add('password', 'repeated', array( // … same before 'first_name' => 'passwd', 'second_name' => 'passwd_confirm', // new since 2.1 'first_options' => array('label' => 'password'), 'second_options' => array('label' => 'password confirmation'), ));

php symfony2

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -