user1175817
user1175817

Reputation: 489

Multiple forms on a single page cakephp with one submit

So I want to do something like this:

for($i=1; $i <= 30; $i++)
    echo $form->Create('Sales');
    echo $form->input('price');
    echo $form->input ......

endfor;
echo->$form('submit');

And what should get sent to a controller is an array of 30 arrays all of type sales. Currently only getting one array back--data from the last form. So on every iteration on the loop it is overwriting the previous form.

Upvotes: 0

Views: 859

Answers (2)

nepalipunk
nepalipunk

Reputation: 744

To post data, in SalesController

public function add(){
    ...
    $this->Sales->saveMany($this->request->data);
    ...

Upvotes: 0

chetanspeed511987
chetanspeed511987

Reputation: 2025

You should not repeat FORM ,just repeat TEXT FIELD like below

    echo $form->Create('Sales');
    for($i=1; $i = 30; $i++)
      echo $form->input('Sales.'$i'.price');
      echo $form->input ......
    endfor;
    echo->$form('submit');

Upvotes: 1

Related Questions