Issue
After many hours of searching in Net I decided to post my question here hoping to find the solution
Here is my code in my View add_by_complex.ctp
:
<div class="immeubles form large-10 medium-9 columns content">
<?= $this->Form->create($immeuble); /* line 9 */ ?>
<fieldset>
<legend><?= __('Ajouter un immeuble') ?></legend>
<?php echo $this->Form->input('name',['label' => 'Nom']); ?>
</fieldset>
<?= $this->Form->button(__('Valider')) ?>
<?= $this->Form->end() ?>
</div>
Here is the error message :
Notice (8): Undefined variable: immeuble
[APP/Template\Immeubles\add_by_complex.ctp, line 9]
What is the problem? thanks lot
Solution
When creating forms with a context, you will have to provide an Entity or ArrayContext to the create()
method form.
The $model argument is used as the form’s ‘context’. There are several built-in form contexts and you can add your own, which we’ll cover in the next section. The built-in providers map to the following values of $model:
http://book.cakephp.org/3.0/en/views/helpers/form.html#starting-a-form
If you do not provide any parameters, it will assume that you are building just a form that submits to the controller.
To be able to access the Entity, or any other, variable in a View you'll have to set the View variable
Answered By - Sevvlor
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.