Reputation: 489
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
Reputation: 744
To post data, in SalesController
public function add(){
...
$this->Sales->saveMany($this->request->data);
...
Upvotes: 0
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