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 7083401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:10:24+00:00 2026-05-28T07:10:24+00:00

I have a simple crud application, and the edit page in my controller is

  • 0

I have a simple crud application,
and the edit page in my controller is like so:

    function admin_edit($id = null) {

        if (empty($this->data)) {
            $this->data = $this->Product->read(); //product is the model

        } else {
           //its a post request, and $this->data is populated 
            debug($this->data);     

            //i force the id to another id
            $this->data["Product"]["id"] = 115;

            debug($this->data); //the data remains the same, doesnt change.. why?   

           //i will save this later         
        }
}

Both debugs result in this:

before

Array
(
    [Product] => Array
        (
            [id] => 8
            [alias] => ME
            [order] => 80
            [open_close_images] => 1
            [gallery_id] => 8
            [video_id] => 2
        )
)

after:

Array
(
    [Product] => Array
        (
            [id] => 8 //it must be 115 now!!
            [alias] => ME
            [order] => 80
            [open_close_images] => 1
            [gallery_id] => 8
            [video_id] => 2
        )
)

Why this?

In cakephp 1.3 that worked well, i don’t understand how it can be possible to “lock” that array.

  • 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-05-28T07:10:24+00:00Added an answer on May 28, 2026 at 7:10 am

    Try setting the id by (re-)setting the Model’s id var, like this:

    $this->Product->id = 115;
    

    That should update the id properly.

    EDIT

    If you’re trying to update other values, use $this->request->data instead (it’s called that since CakePHP 2.0), for example:

    $this->request->data['Product']['id'] = 115;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Crud application where there is one filed called Category. During
I am working on my second CI application. I have created some simple CRUD
I have a fairly simple CRUD web application (C#/ASP.NET) that runs fine in Firefox,
I'm recently have learned to use Zend Framework. I did a simple CRUD application.
I have a simple mvc application which perform the CRUD functionality to manage UserDetials.
I have a SQL Express database, and I'd like a very simple forms application
I have a simple application using the Play! framework's secure module. My 'Users' controller
I have written a simple CRUD form which has one select list. However the
I have simple SSIS package which reads data from flat file and insert into
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script

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.