forms - NotBlank assert and "must be of the type string, null given" -




with symfony 3.3, have entity notblank assert :

class usercontributorversion {     /**      * @var string      *      * @orm\column(type="string")      * @assert\notblank()      */     private $name;      /**      * set name      *       * @param string $name      */     public function setname(string $name)     {         $this->name = $name;     } } 

but if validate form novalidate attribute, have error :

argument 1 passed appbundle\entity\usercontributorversion::setname() must of type string, null given

i don't understand, why force setname(string $name = null) if have notblank assert ?

thanks :)

validation performed on form data. if form supposed entity (option data_class set) form data entity should modified. validation performed after request values set form data (in case entity) fields.

you can find form submit flow here: https://symfony.com/doc/current/form/events.html#submitting-a-form-formevents-pre-submit-formevents-submit-and-formevents-post-submit

enter image description here

validation registered formevents::post_submit event. request values set form data before post_submit event.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -