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

  • Home
  • SEARCH
  • 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 7770999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:32:30+00:00 2026-06-01T16:32:30+00:00

Im using cake 2.0.6 and im trying to save multiple records that are products

  • 0

Im using cake 2.0.6 and im trying to save multiple records that are products my data output from the form is below;

I cant get it to save the two records, the fields in my form are set like; with 0 being the first record it should save. It wont save the 2 records for some reason. Ive turned off all validation for the product model and have no beforesave method

Any ideas whats wrong?

<input name="data[Product][0][product_code]"/>
<input name="data[Product][0][colour]"/>
<input name="data[Product][0][lead_time_weeks]"/>
<input name="data[Product][0][description]"/>
<input name="data[Product][0][height]" />
<input name="data[Product][0][width]" />
<input name="data[Product][0][depth]" />
<input name="data[Product][0][price]" />
<input name="data[Product][0][discount]" />
<input name="data[Product][0][discounted_price]" />
<input name="data[Product][0][quantity]"/>


<input name="data[Product][1][product_code]"/>
<input name="data[Product][1][colour]"/>
<input name="data[Product][1][lead_time_weeks]"/>
<input name="data[Product][1][description]"/>
<input name="data[Product][1][height]" />
<input name="data[Product][1][width]" />
<input name="data[Product][1][depth]" />
<input name="data[Product][1][price]" />
<input name="data[Product][1][discount]" />
<input name="data[Product][1][discounted_price]" />
<input name="data[Product][1][quantity]"/>


Array
(
    [Product] => Array
        (
            [0] => Array
                (
                    [product_code] => fgfgf
                    [colour] => 
                    [lead_time_weeks] => 
                    [description] => 
                    [height] => 11111
                    [width] => 22222
                    [depth] => 
                    [price] => 
                    [discount] => 50
                    [discounted_price] => 
                    [quantity] => 
                )

            [1] => Array
                (
                    [product_code] => fgfgf
                    [colour] => 
                    [lead_time_weeks] => 
                    [description] => 
                    [height] => 123
                    [width] => 123
                    [depth] => 
                    [price] => 
                    [discount] => 50
                    [discounted_price] => 
                    [quantity] => 
                )

        )

)

EDIT:
Solution for future reference;
Call the save method like this;

$this->Product->saveAll($this->request->data[‘Product’]

  • 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-01T16:32:31+00:00Added an answer on June 1, 2026 at 4:32 pm

    How do you call saveAll? The common mistake is to call it like

    $this->Product->saveAll($data);
    

    When you should have done it like

    $this->Product->saveAll($data['Product']);
    

    It has to be numerically indexed without the Model key

    As per the docs:
    https://book.cakephp.org/2.0/en/models/saving-your-data.html

    Note that we are passing $data[‘Article’] instead of usual $data. When
    saving multiple records of same model the records arrays should be
    just numerically indexed without the model key.

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

Sidebar

Related Questions

Using CakePHP 1.3 I'm trying to save some data to a MySQL database. The
i am trying to do a simple form that adds a new comment using
Is it possible to load a single plugin from outside the cake root using
Using ASP.NET MVC there are situations (such as form submission) that may require a
I'm trying to create a form using Cakephp's FormHelper class. The form needs to
Using the form helper in CakePHP 1.3, I'm trying to display a list (drop-down
Im trying to make a front page for a website using cake. I want
I am trying to display an image from the /webroot/img/ folder using the following
I'm trying to set up 'cake bake' on OS X. I'm using MAMP and
I am trying to build a form that consists of Subjects, which belong to

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.