php - Symfony form validate selected members of entity -


i using symfony form validating login data tie entity class (which has validation defined members) , need form validate email , password portion. in form class, don't add email , password form. however, when data submitted, still validates them , shows errors @ top of form

how not validate other members(city, sex, etc) without changing entity class.

so there's entity class : name, email, sex, password, city. fields required

login form email , password. still errors other two

use validation groups ...

entity class :

// src/acme/blogbundle/entity/user.php namespace acme\blogbundle\entity;  use symfony\component\security\core\user\userinterface; use symfony\component\validator\constraints assert;  class user implements userinterface {     /**     * @assert\email(groups={"registration"})     */     private $email;      /**     * @assert\notblank(groups={"registration"})     * @assert\length(min=7, groups={"registration"})     */     private $password;      /**     * @assert\length(min = "2")     */     private $city; } 

then when create form :

$form = $this->createformbuilder($users, array(     'validation_groups' => array('registration'), ))->add(...); 

this validate email , password fields.

docs on validation groups here , here


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -