php - Symfony2 parameter with embedded forms -
edit : find real problem ! trying give paramater sub-form controller. without parameter, form working perfectly.
i want show in select list user wich not present in relation. have query_builder :
'query_builder' => function(userrepository $er) use($options) { return $er->getformateursavailable($options['categ']); },
and method :
public function setdefaultoptions(optionsresolverinterface $resolver) { $resolver->setdefaults(array('data_class' => 'intranet\formationbundle\entity\categorieformateur', 'categ' => false)); //$resolver->setdefaults(array('data_class' => 'intranet\formationbundle\entity\categorieformateur')); }
for collection form, so, have put option in form :
'options' => $options,
but don't know if true, , have define method :
public function setdefaultoptions(optionsresolverinterface $resolver) { $resolver->setdefaults(array('categ' => false)); }
(the form working without method if there no parameter.) , calling :
$form = $this->createform(new gererformateurcategorietype(), $categorie, array('categ' => $categorie));
and then, have error :
neither property "user" nor 1 of methods "getuser()", "isuser()", "hasuser()", "__get()" exist , have public access in class "intranet\formationbundle\entity\categorie".
the relation :
categorie haves property :
/** * @orm\onetomany(targetentity="intranet\formationbundle\entity\categorieformateur", mappedby="categorie", cascade={"persist", "remove"}, orphanremoval=true) **/ private $formateurs;
with addformateur, removeformateur , getformateurs
categorieformateur :
/** * @orm\id * @orm\manytoone(targetentity="intranet\formationbundle\entity\categorie", inversedby="formateurs") * @orm\joincolumn(name="categorie_id", referencedcolumnname="id") */ private $categorie; /** * @orm\id * @orm\manytoone(targetentity="intranet\userbundle\entity\user") * @orm\joincolumn(name="user_id", referencedcolumnname="id") */ private $user;
with setters , getters each properties
according error message, have add setformateurs()
method in categorie
entity:
public function setformateurs($formateurs) { $this->formateurs = $formateurs; return $this; }
Comments
Post a Comment