Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7811289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:06:22+00:00 2026-06-02T04:06:22+00:00

I am facing a strange problem while creating edit functionality in cakephp 2.1 Error

  • 0

I am facing a strange problem while creating edit functionality in cakephp 2.1

Error genreated:
Illegal offset type [CORE\Cake\Model\Model.php, line 2689]

My edit.ctp file is

<?php echo $this->Form->create('Task');?>
<fieldset>
<legend>Edit Task</legend>

<?php
   echo $this->Form->hidden('id');
   echo $this->Form->input('title');
   echo $this->Form->input('done');
?>

</fieldset>
<?php echo $this->Form->end('Save');?>

Model: Task.php

 <?php
    class Task extends AppModel {
        var $name = 'Task';
    }
    ?>

Controller :TasksController.php

    <?php

        class TasksController extends AppController {
            var $name = 'Tasks';
            var $helpers = array('Html', 'Form');
            function index() {
                $this->set('tasks', $this->Task->find('all'));
            }
            function add() {
                if (!empty($this->data)) {

                $this->Task->create();
                if($this->Task->save($this->data)){
                    $this->Session->setFlash('The Task has been saved');
                    $this->redirect(array('action'=>'index'),null,true);
                }else{
                    $this->Session->setFlash('Task not saved.Try again.');
                }      

            }
        }
        function edit($id = null) {
            if (!$id) {
                $this->Session->setFlash('Invalid Task');
                $this->redirect(array('action' => 'index'), null, true);
            }
            if (empty($this->data)) {
                $this->data = $this->Task->find(array('id' => $id));
            } else {
                if ($this->Task->save($this->data)) {
                    $this->Session->setFlash('The Task has been saved');
                    $this->redirect(array('action' => 'index'), null, true);
                } else {
                    $this->Session->setFlash('The Task could not be saved.Please, try again.');
                }
            }
        }
    }

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:06:24+00:00Added an answer on June 2, 2026 at 4:06 am

    I think your find() method is erroneous:

    $this->data = $this->Task->find(array('id' => $id));
    

    change to

    $this->data = $this->Task->find('all', array('conditions' => array('id' => $id)));
    

    http://book.cakephp.org/2.0/en/models/retrieving-your-data.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing a strange problem while creating a file in java using MYSQL.
I have been facing a strange problem while returning dataset through WCF service (WSHttpBinding).
I am facing this strange problem while working with Generic Base Classes. I am
I am facing a really strange problem with Core Data. Let's describe it: Definitions
I am facing a strange problem while running my application. I have a class
I am facing a strange problem while sorting a list of strings with integer
today i was facing a strange problem: got a 'missing method' error on a
I am facing strange problem in opera while using cufon with dd_belatedPNG and dd_roundies.
I am facing a strange problem in cakePHP. The issue is when ever i
I am facing a strange problem on my Ubuntu Karmic system. When I call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.