symfony form entity update -


i'm trying create entity.

my controller:

$questionnaire = $em->getrepository('questionnairebundle:questionnaire')->findoneby(array('id' => $id));          $form = $this->createform(new questionnairetype(), $questionnaire); 

questionnairetype:

public function buildform(formbuilderinterface $builder, array $options) {     $builder->add('nom', 'text', array('label' => 'nom:'));     $builder->add('nbrequestions', 'text', array('label' => 'nombre de questions:'));     $builder->add('type', 'entity', array('class' => 'questionnairebundle:type', 'property' => 'type'));     $builder->add('envoyer', 'submit', array('label' => 'enregistrer', 'attr' => array('class' => 'btn btn-success col-md-12'))); } 

the entity: questionnaire

namespace questionnairebundle\entity;  use doctrine\orm\mapping orm; use symfony\component\validator\constraints assert;  /**  * questionnaire  *  * @orm\table()  * @orm\entity  */ class questionnaire {      /**      * @var integer      *      * @orm\column(name="id", type="integer")      * @orm\id      * @orm\generatedvalue(strategy="auto")      */     private $id;      /**      * @var string      *      * @orm\column(name="nom", type="string", length=255)      */     private $nom;     /**      * @var string      *      * @orm\column(name="type", type="string", length=255)      */     private $type;      /**      * @var integer      *      * @orm\column(name="nbrequestions", type="integer")      *      * @assert\notblank(message="veuillez entrer un nombre de questions.")      * @assert\type(type="integer")      */     private $nbrequestions;      /**      * id      *      * @return integer       */     public function getid() {         return $this->id;     }      /**      * set nom      *      * @param string $nom      * @return questionnaire      */     public function setnom($nom) {         $this->nom = $nom;          return $this;     }      /**      * nom      *      * @return string       */     public function getnom() {         return $this->nom;     }     /**      * set type      *      * @param string $type      * @return type      */     public function settype($type) {         $this->type = $type;          return $this;     }      /**      * type      *      * @return string       */     public function gettype() {         return $this->type;     }      /**      * set nbrequestions      *      * @param integer $nbrequestions      * @return questionnaire      */     public function setnbrequestions($nbrequestions) {         $this->nbrequestions = $nbrequestions;          return $this;     }      /**      * nbrequestions      *      * @return integer       */     public function getnbrequestions() {         return $this->nbrequestions;     }      public function __tostring() {         return (string) $this->getnom();     }  } 

the field nom, nbrequestions automatically entity questionnaire, type not update!

anybody knows why?

thanks best regards

that must second query behind sense, can increase performance dql & join:

use code:

$questionnaire = $em->createquery('select q questionnairebundle:questionnaire q join q.type t q.id = :id')->setparameter('id', $id)->getsingleresult();  $form = $this->createform(new questionnairetype(), $questionnaire); 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -