PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 21, 2022

[FIXED] Notice (8): Undefined variable cakePHP 3

 February 21, 2022     cakephp-3.0, cakephp-3.x     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing