CakePHP save multiple rows

cakephp, cakephp-2.0

Solution

You should specify the model of each field if you have more models involved. Also, you need to specify for each record the related field (user_id).

Try this:

echo $this->Form->input('UserImage.0.user_id');
echo $this->Form->input('UserImage.1.user_id');

Plus use this to save multiple records and multiple models:

$this->UserImage->saveAll($this->request->data);

Problem

I am using two models 'User' and 'UserImage'.. Where in i am going to save multiple rows into user_images table.. The view for UserImage is below.. ``` echo $this->Form->input('UserImage.0.photo'); echo $this->Form->input('UserImage.1.photo'); echo $this->Form->input('user_id'); echo $this->Form->end(__('Submit')); ``` Then how to save multiple rows..

Original source