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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:24:31+00:00 2026-05-13T18:24:31+00:00

In the cakePHP project I’m building, I want to insert a defined number of

  • 0

In the cakePHP project I’m building, I want to insert a defined number of identical records. These will serve as placeholders records that will have additional data added later. Each record will insert the IDs taken from two belongs_to relationships as well as two other string values.

What I want to do is be able to enter a value for the number of records I want created, which would equate to how many times the data is looped during save.

What I don’t know is:

  1. how to setup a loop to handle a set number of inserts

  2. how to define a form field in cakePHP that only sets the number of records to create.

What I’ve tried is the following:

function  massAdd() {
    $inserts_required = 1;
    while ($inserts_required <= 10) {
        $this->Match->create();
        $this->Match->save($this->data);
        echo $inserts_required++;
    }

    $brackets = $this->Match->Bracket->find('list');
    $this->set(compact('brackets'));
}

What happens is:

  1. At the top of the screen, above the doc type, the string 12345678910 is displayed, this is displayed on screen

  2. A total of 11 records are created, and only the last record has the values passed in the form. I don’t know why 11 records as opposed to 10 are created, and why only the last records has the entered form data?

As always, your help and direction is appreciated.

  • 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-13T18:24:31+00:00Added an answer on May 13, 2026 at 6:24 pm
    1. in your view try to write something like

      echo $form->input('Answer.n.title', array('type'=>text'));
      

      in controller write

      function add(){
          $this->Answer->saveAll($this->data);
      }
      
    2. in my project I used jQuery, to add a new row without reloading a page.

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

Sidebar

Related Questions

I've got a model in CakePHP that doesn't have a table, called Upload. I've
I've got a CAkePHP 1.2 site. I've got three related Models/tables: A Comment has
In a CakePHP 1.2 app, I'm using <?php $session->flash();?> to output messages like Record
I have a CakePHP 1.2 application. I'm running into the case where I need
I'm new to CakePHP but I've been though their FAQs and guides to no
I've got a simple CakePHP site (1.2) . I've got a page where you
There is no documentation on cakephp.org and I am unable to find one on
I am creating a website in CakePHP and I am kind of new on
I'm using the cacheCounter in CakePHP , which increments a counter for related fields.
I'm struggling to implement ACL in CakePHP. After reading the documentation in the cake

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.