开发者

How to resolve Notice: Undefined variable: form ...?

开发者 https://www.devze.com 2023-03-09 15:32 出处:网络
when I开发者_如何转开发 have created my page indexSuccess.php, i used an instruction like : <?php echo $form[\'titre\']->render();?>

when I开发者_如何转开发 have created my page indexSuccess.php, i used an instruction like :

    <?php echo $form['titre']->render();?>

it gives me an error when executing like :

    Notice: Undefined variable: form in C:\wamp\www\MyProject\apps\frontend\modules\addAnnonce\templates\indexSuccess.php on line 84

    Fatal error: Call to a member function render() on a non-object in C:\wamp\www\MyProject\apps\frontend\modules\addAnnonce\templates\indexSuccess.php on line 84

what can I doas solution for that problem?


When you auto-generate a doctrine model, the form is created as a partial and embedded in the new & edit templates. If you check your newSuccess, createSuccess, editSuccess, updateSuccess actions, you will find the assignment of the form variable as mentioned by prodigitalson, so this error wont appear there.

However, the form is not automatically made available on indexSuccess, as that page by naming convention is supposed to be used for listing out the objects. Breaking the convention might lead to some confusion later.

One more tip: if you want to create a screen similar to the symfony admin backend, where you list all objects along with a form to add/edit objects, you can use generator.yml to automatically generate your views. Be sure to include css,js&images from web/sf folder in the symfony directory


So, I found what I'm searching for. I forgot to add

  $this->form = new addAnnonceForm();

in my executeIndex(action)

thx :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号