doctrine2 - error `the name contains illegal characters`, in Doctrine 2 embeddable in Symfony 2,8 form -


doctrine 2 annotation embeddable not working in symfony 2.8 on windows.

@orm\embeddable not working, getting error : name "address.addr_line_1" contains illegal characters. names should start letter, digit or underscore , contain letters, digits, numbers, underscores ("_"), hyphens ("-") , colons (":"). error comes vendor...\src\symfony\component\form\formconfigbuilder.php .

seems reason dot in automatically generated name : "address.addr_line_1".

i tried disable automatic prefixes, , give own names. doctrine generates table columns names wrote : addr_line_1.

but generated form contain fields dot "address.addr_line_1", though error the name xxx contains illegal characters.

if use addr_line_1 in form, getting error, name not exists.

<?php  namespace learn\mysqlbundle\entity;  use doctrine\orm\mapping orm; //use doctrine\orm\mapping\embeddable;  use learn\mysqlbundle\entity\embeddable\addressemb; use learn\mysqlbundle\entity\embeddable\telemb;  /**  * @orm\table( name="te12authoremb" )  * @orm\entity()  */ class e12authoremb {      /**      * @orm\id      * @orm\column(type="string", length=36)      * @orm\generatedvalue(strategy="custom")      * @orm\customidgenerator(class="learn\mysqlbundle\doctrine\generator6")      */     protected $id;     /**      * @var string      *      * @orm\column(name="name", type="string")      */     protected $name;      // columnprefix = "address_"     /** @orm\embedded( class="learn\mysqlbundle\entity\embeddable\addressemb", columnprefix=false ) */     protected $address;      /** @var string @orm\column(type="string", length=200) */     protected $email = '';      // if there \learn.. cmd not generate entities , crud, columnprefix = "tel_"      /** @orm\embedded( class="learn\mysqlbundle\entity\embeddable\telemb", columnprefix=false ) */     protected $tel = '';          public function __construct()     {         $this->address = new addressemb();         $this->tel = new telemb();     }       /**      * set id      *      * @param string $id      *      * @return e5author      */     public function setid($id)     {         $this->id = $id;          return $this;     }      /**      * id      *      * @return string      */     public function getid()     {         return $this->id;     }      /**      * set name      *      * @param string $name      *      * @return e5author      */     public function setname($name)     {         $this->name = $name;          return $this;     }      /**      * name      *      * @return string      */     public function getname()     {         return $this->name;     }       /**      * set email      *      * @param string $email      *      * @return e10authoremb      */     public function setemail($email)     {         $this->email = $email;          return $this;     }      /**      * email      *      * @return string      */     public function getemail()     {         return $this->email;     }      /**      * set address      *      * @param \learn\mysqlbundle\entity\embeddable\addressemb $address      *      * @return e10authoremb      */     public function setaddress(\learn\mysqlbundle\entity\embeddable\addressemb $address)     {         $this->address = $address;          return $this;     }      /**      * address      *      * @return \learn\mysqlbundle\entity\embeddable\addressemb      */     public function getaddress()     {         return $this->address;     }      /**      * set tel      *      * @param \learn\mysqlbundle\entity\embeddable\telemb $tel      *      * @return e10authoremb      */     public function settel(\learn\mysqlbundle\entity\embeddable\telemb $tel)     {         $this->tel = $tel;          return $this;     }      /**      * tel      *      * @return \learn\mysqlbundle\entity\embeddable\telemb      */     public function gettel()     {         return $this->tel;     } } 

,,

<?php  namespace learn\mysqlbundle\entity\embeddable;  use doctrine\orm\mapping orm;  /**  * description of addressemb  *  * @author gintare  */ /** @orm\embeddable */ class addressemb  {     /**  @orm\column( name="addr_line_1", type = "string", nullable=true) */     protected $addr_line_1 = "";     /**  @orm\column( name="addr_line_2", type = "string", nullable=true) */     protected $addr_line_2 = "";     /** @orm\column( name="addr_town", type = "string", nullable=true) */     protected $addr_town = "";     /**  @orm\column( name="addr_state", type = "string", nullable=true) */     protected $addr_state = "";     /**  @orm\column( name="addr_postcode", type = "string", nullable=true) */     protected $addr_postcode = "";     /* may relation other entity @var \entities\country * */     /**  @orm\column( name="addr_country", type = "string", nullable=true) */     protected $addr_country;      public function __construct( $line_1 = null, $line_2 = null, $town = null,                                   $state = null, $postcode = null, $country=null )     {         $this->addr_line_1 = $line_1;         $this->addr_line_2 = $line_2;         $this->addr_town = $town;         $this->addr_state = $state;         $this->addr_postcode = $postcode;         $this->addr_country = $country;     } }   <?php  namespace learn\mysqlbundle\entity\embeddable;  use doctrine\orm\mapping orm; //use doctrine\orm\mapping\embeddable;  /**  * telemb - value object represent telephone code country  *  * @author gintare  */ /** @orm\embeddable */ class telemb  {     /** @orm\column( name="tel_number", type = "string", nullable=true) */     protected $tel_number = "";     /* *@orm\column( name="tel_countrycode", type = "string", nullable=true) */     protected $tel_countrycode = "";     /** @orm\column( name="tel_country", type = "string", nullable=true) */     protected $tel_country;     /** @orm\column( name="tel_type", type = "string", nullable=true) */     protected $tel_type; //mobile, landline,     /** @orm\column( name="tel_costinfo", type = "string", nullable=true) */     protected $tel_costinfo; // information cost     /** @orm\column( name="tel_accessinfo", type = "string", nullable=true) */     protected $tel_accessinfo; // information abotu accessability      public function __construct( $number = null, $countrycode = null, $country = null,                                 $accessinfo = null, $costinfo = null, $type = null )     {         $this->tel_number = $number;         $this->tel_countrycode = $countrycode;         $this->tel_country = $country;         $this->tel_accessinfo = $accessinfo;         $this->tel_costinfo = $costinfo;         $this->tel_type = $type;     } } 

one of solutions put permission use dot in c:\bitnami\wampstack-5.6.20-0\apache2\htdocs\sym\learndb\vendor\symfony\symfony\src\symfony\component\form\formconfigbuilder.php.

return '' === $name || null === $name || preg_match('/^[a-za-z0-9_][a-za-z0-9_\.\-:]*$/d', $name);    

this works, new form generated, did not proceed futher yet, because need generate special getters , setters in embeddable. seems best solution use trait described here: http://russellscottwalker.blogspot.co.uk/2013/11/entities-vs-value-objects-and-doctrine-2.html

nevertheless, if knows how make embedable work, without changing symfony vendor code, please write.

maybe work direct queries select o order o o.address.addr_line_1 = : line1 http://welcometothebundle.com/persist-the-money-doctrine-value-object/ not work symfony form.

new versions of doctrine doesn't allow special characters underscores. have tried without them?

write variables, classes , folders in camel case considered practice also.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -