saving in two tables using one form

hi guys please help i’m a codeigniter developer and trying to learn yii.

my problem is i want to save data to two tables were one data is the employee and the other is EmployeeChildren

the EmployeeChildren should be an array since one employee can have many the idea is to have a text box for employee fields and a list for EmployeeChildren field an add button where i can add children to list and save button to save all the data to there respective table.



  1. Employee



  1. EmployeeChildren




the form design should be like this

text[employeeId] List[Children]

text[name] button[add] button[remove]


yes you can pass the array in controller ,

in controller make two object of different model and you can save different array elements in different table using model of that table .

Take a look at this wiki.

thanks for the reply guys.

now how do i save the children where children are in array.










any sample code for this?.

I got it! thanks for hint guys…

Hello scrypt new to Yii here. Can i ask how did you do it?

saving one-to-many in one form.



Have a look at this wiki as well.

See the "Another use case" section. It displays a parent record at the top and child records below that in a CGridView and dropdownlist. It saves the parent record and selected child records from the dropdownlist simultaneously.

thanks gerhard… i will look into that article.

please see the above link and help me to save the data to db…i’m also have the same problem but i don’t know how to do that…there i post my code so plz help me …