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 children.so 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.
Design:
Tables:
1. Employee
-employeeId
-name
2. EmployeeChildren
-employeeId
-childName
-birthDate
the form design should be like this
text[employeeId] List[Children]
text[name] button[add] button[remove]
button[Save]
Page 1 of 1
saving in two tables using one form saving data in two tables using one form
#2
Posted 30 June 2011 - 01:01 AM
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 .
in controller make two object of different model and you can save different array elements in different table using model of that table .
Thanks,
Kiran Sharma.
Kiran Sharma.
#4
Posted 03 July 2011 - 11:12 PM
thanks for the reply guys.
now how do i save the children where children are in array.
employe:
001
scrypt
i.t
children:
1
boy
2
girl
any sample code for this?.
now how do i save the children where children are in array.
employe:
001
scrypt
i.t
children:
1
boy
2
girl
any sample code for this?.
#7
Posted 11 July 2012 - 03:17 PM
Have a look at this wiki as well.
http://www.yiiframew...as-clicked/#hh7
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.
http://www.yiiframew...as-clicked/#hh7
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.
#8
Posted 11 July 2012 - 08:08 PM
Gerhard Liebenberg, on 11 July 2012 - 03:17 PM, said:
Have a look at this wiki as well.
http://www.yiiframew...as-clicked/#hh7
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.
http://www.yiiframew...as-clicked/#hh7
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.
Share this topic:
Page 1 of 1

Help














