Yii Framework Forum: How To Save The Same Model Multiple Times - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Save The Same Model Multiple Times

#1 User is offline   SUBHASH 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 08-November 12

Posted 02 December 2012 - 11:57 PM

Here i am saving the same model multiple times depending upon the user . I kept two fields one is title and text
and if user click add button then another two fields will added and soon but while i am saving these models in the controller i able to save the last fields only

my controller is

if (isset($_POST['Task']))
{

foreach($_POST['Task'] as $i => $item)
{
$model->attributes = $_POST['Task'][$i];
print_r($model->attributes);
//$model->save();
}

}

and while print the array using print_r() it is getting all the fields value ex

Array ( [title] => title1 [id] => [text] => ) Array ( [title] => title1 [text] => text1 [id] => ) Array ( [title] => title4 [text] => text1 [id] => ) Array ( [title] => title4 [text] => text4 [id] => )


can anyone help me in saving all these values
0

#2 User is offline   kiran sharma 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 494
  • Joined: 21-May 11
  • Location:India

Posted 03 December 2012 - 01:04 AM

This two links might be useful..
Wiki article
Guide topic
Thanks,
Kiran Sharma.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users