Note that there are some explanatory texts on larger screens.

plurals
  1. POCakephp Model error
    text
    copied!<p>I am facing a strange problem while creating edit functionality in cakephp 2.1</p> <p>Error genreated: Illegal offset type [CORE\Cake\Model\Model.php, line 2689]</p> <p>My edit.ctp file is</p> <pre><code>&lt;?php echo $this-&gt;Form-&gt;create('Task');?&gt; &lt;fieldset&gt; &lt;legend&gt;Edit Task&lt;/legend&gt; &lt;?php echo $this-&gt;Form-&gt;hidden('id'); echo $this-&gt;Form-&gt;input('title'); echo $this-&gt;Form-&gt;input('done'); ?&gt; &lt;/fieldset&gt; &lt;?php echo $this-&gt;Form-&gt;end('Save');?&gt; </code></pre> <p>Model: Task.php</p> <pre><code> &lt;?php class Task extends AppModel { var $name = 'Task'; } ?&gt; </code></pre> <p>Controller :TasksController.php</p> <pre><code> &lt;?php class TasksController extends AppController { var $name = 'Tasks'; var $helpers = array('Html', 'Form'); function index() { $this-&gt;set('tasks', $this-&gt;Task-&gt;find('all')); } function add() { if (!empty($this-&gt;data)) { $this-&gt;Task-&gt;create(); if($this-&gt;Task-&gt;save($this-&gt;data)){ $this-&gt;Session-&gt;setFlash('The Task has been saved'); $this-&gt;redirect(array('action'=&gt;'index'),null,true); }else{ $this-&gt;Session-&gt;setFlash('Task not saved.Try again.'); } } } function edit($id = null) { if (!$id) { $this-&gt;Session-&gt;setFlash('Invalid Task'); $this-&gt;redirect(array('action' =&gt; 'index'), null, true); } if (empty($this-&gt;data)) { $this-&gt;data = $this-&gt;Task-&gt;find(array('id' =&gt; $id)); } else { if ($this-&gt;Task-&gt;save($this-&gt;data)) { $this-&gt;Session-&gt;setFlash('The Task has been saved'); $this-&gt;redirect(array('action' =&gt; 'index'), null, true); } else { $this-&gt;Session-&gt;setFlash('The Task could not be saved.Please, try again.'); } } } } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload