php - symfony : get object Forms -


how can object attributes use build form : controller code

$assistance1 = new assistance(); $assistance1->setetudiant($etudiant1); $form = $this->get('form.factory')->create(new assistancetype(), $assistance1); 

buildform function on form class

/**  * @param formbuilderinterface $builder  * @param array $options  */ public function buildform(formbuilderinterface $builder, array $options) {      $builder         ->add('present', 'checkbox',array(             'required'  => false,         ))     ; } 

you add $this->assistance1; assistencetype , new assistencetype($assistence1); not design imo.

class assistencetype extends abstracttype {     private $assistence1;      public function __construct($assistence1)     {         $this->assistence1 = $assistence1;     }      public function buidlform(formbuilderinterface $builder, array $options)     {         $builder->add('present', 'checkbox', array(             'required' => false,             'label' => $this->assistence1->getetudiant()         ));     } } 

and use this

$form = $this->get('form.factory')->create(new assistancetype($assistence1), $assistance1); 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -