php - Symfony2 Object of class could not be converted to string error on the simplest code -


i have simplest code ever, , cant understand why hell error. want create form create new email message... looks simple, yet doesnt work....

here error:

contexterrorexception: catchable fatal error: object of class mediaparklt\userbundle\entity\email not converted string in c:\wamp\www\digidis\front\app\cache\dev\twig\e4\61\15c5455e50341edc1387cde083d07297f9c2cb3fe9cf4782bd2ed3ead531.php line 172 

i tried clearing cache.

this entity:

<?php /**  * created phpstorm.  * user: domas  * date: 6/10/2015  * time: 2:18 pm  */  namespace mediaparklt\userbundle\entity;  use doctrine\common\collections\collection; use doctrine\orm\mapping orm; use mp\cmsbundle\entity\cmselement; use mp\cmsbundle\entity\cmsimage; use mp\cmsbundle\entity\cmsimagegallery; use mediaparklt\lotterybundle\entity\product; use mediaparklt\skinbundle\entity\urlskin; use symfony\component\httpfoundation\file\uploadedfile; use symfony\component\validator\constraints assert;  /**  * mediaparklt\userbundle\entity\email  *  * @orm\entity  * @orm\table(name="email")  */ class email {      /**      * @var integer $id      *      * @orm\column(name="id", type="integer")      * @orm\id      */     protected $id;      /**      * @var string $title      *      * @orm\column(name="title", type="string")      */     protected $title;      /**      * @var string $title      *      * @orm\column(name="content", type="string")      */     protected $content;      /**      * id      *      * @return integer      */     public function getid()     {         return $this->id;     }      public function setid() {         $this->id = null;     }      /**      * set title      *      * @param string $title      * @return email      */     public function settitle($title)     {         $this->title = $title;          return $this;     }      /**      * title      *      * @return string      */     public function gettitle()     {         return $this->title;     }      /**      * set content      *      * @param string $content      * @return email      */     public function setcontent($content)     {         $this->content = $content;          return $this;     }      /**      * content      *      * @return string      */     public function getcontent()     {         return $this->content;     } }  

this form want create:

<?php /**  * created phpstorm.  * user: domas  * date: 6/10/2015  * time: 2:51 pm  */  namespace mediaparklt\skinbundle\form\type;  use mediaparklt\mainbundle\form\type\translatabletype; use symfony\component\form\formbuilderinterface; use symfony\component\form\formtypeinterface; use symfony\component\optionsresolver\optionsresolverinterface; use symfony\component\form\abstracttype;  class emailtype extends abstracttype {      public function buildform(formbuilderinterface $builder, array $option) {         $builder->add('title', 'text', array('label' => 'cms.title'));          $builder->add('content', 'text', array('label' => 'cms.content'));     }      public function getdefaultoptions(array $options) {         return array(             'data_class' => 'mediaparklt\userbundle\entity\email',         );     }       public function getname()     {         return 'email';     } } 

someone help!

i see 2 possible problems:

  1. as @gerry suggested in comment, might rendering entity in twig template in manner:

    {{ email }} 

    and since email entity does not have __tostring fails.

  2. you getname() returns email. believe symfony2 has form type name registered internally emailtype. so, symfony might thinking trying render internal emailtype instead of own.

    try changing name my_email.

hope helps.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -