symfony annotations validation override entities/models -


i'm trying override entities validatation of forum bundle. this:

category entity:

//src/msd/forobundle/entity/category.php  namespace msd\forobundle\entity;  use herzult\bundle\forumbundle\entity\category basecategory; use doctrine\orm\mapping orm;   /**  * @orm\entity(repositoryclass="herzult\bundle\forumbundle\entity\categoryrepository")  */ class category extends basecategory { } 

topic entity:

//src/msd/forobundle/entity/topic.php  namespace msd\forobundle\entity;  use herzult\bundle\forumbundle\entity\topic basetopic; use doctrine\orm\mapping orm; use symfony\component\validator\constraints assert;  /**  * topic  *  * @orm\entity(repositoryclass="herzult\bundle\forumbundle\entity\topicrepository")  *  */ class topic extends basetopic { /**  * @orm\manytoone(targetentity="category")  */ protected $category;  /**  * @assert\notblank()  * @assert\minlength(limit=4, message="just little short| ")  * @assert\regex( * pattern="/^[a-za-z0-9\-_¿?!¡ ]{4,50}$/", * message="el tema puede contener letras, nĂºmeros, guiones y espacios, interrogantes y exclamaciones. entre 4 y 30 caracteres" * ) */ protected $subject;  /**  * {@inheritdoc}  */ public function getauthorname() {     return $this->author; }  /**  * @orm\manytoone(targetentity="user")  */ private $author;  public function setauthor(user $user) {     $this->author = $user; }  public function getauthor() {     return $this->author; } } 

post entity:

//src/msd/forobundle/entity/post.php  namespace msd\forobundle\entity;  use herzult\bundle\forumbundle\entity\post basepost; use doctrine\orm\mapping orm; use symfony\component\validator\constraints assert;  /**  * @orm\entity(repositoryclass="herzult\bundle\forumbundle\entity\postrepository")  */ class post extends basepost { /**  * @orm\manytoone(targetentity="topic")  */ protected $topic;   /**  * @assert\regex( * pattern="/^[^<>]{4,1000}$/", * message="el mensaje no puede contener '<' ni '>'. entre 4 y 1000 caracteres" * )  *  */ public $message;  public function getauthorname() {     return $this->author; } /**  * @orm\manytoone(targetentity="user")  */ private $author;  public function setauthor(user $user) {     $this->author = $user; }  public function getauthor() {     return $this->author; } } 

and validation works... except message of firt post!! created when new topic created. i've tried many changes, without success. idea of why happend?

thank you

yeah! got it. solution add in topic entity:

/**  * @assert\notblank  * @assert\valid  */ protected $firstpost; 

then, message of first post validated.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -