tag:blogger.com,1999:blog-7303829017133230496.post6360732746036266056..comments2023-06-03T01:55:26.318-04:00Comments on Adventures in Programming: Posting with multiple modelsDana Lutherhttp://www.blogger.com/profile/07289965994216523233noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-7303829017133230496.post-53134001730556893032010-11-09T17:30:44.494-05:002010-11-09T17:30:44.494-05:00To use your example:
$form->textField($a, '...To use your example:<br /><br />$form->textField($a, 'field1', array('name'=>'Class1[0][field1]));<br />$form->textField($b, 'field1', array('name'=>'Class1[1][field1]));<br /><br />Then in the controller:<br /><br />$a = new Class1;<br />$b = new Class1;<br />if ( isset($_POST['Class1']))<br />{<br /> $a->attributes = $_POST['Dana Lutherhttps://www.blogger.com/profile/07289965994216523233noreply@blogger.comtag:blogger.com,1999:blog-7303829017133230496.post-39430776613662050762010-11-09T17:25:26.713-05:002010-11-09T17:25:26.713-05:00Yes, I have. You have to set it up as an array of ...Yes, I have. You have to set it up as an array of $_POST['ObjectName'] items like so:<br /><br />(where $i is the current model count)<br /><br />echo $form->textField($a, 'field1', array('name'=>"ObjectName[$i]['field1']"));<br /><br />Then in your controller, treat the $_POST['ObjectName'] as an array and assign appropriately. Make sense?Dana Lutherhttps://www.blogger.com/profile/07289965994216523233noreply@blogger.comtag:blogger.com,1999:blog-7303829017133230496.post-4743677696943070902010-11-09T17:13:37.792-05:002010-11-09T17:13:37.792-05:00Have you ever tried to post multiple objects of th...Have you ever tried to post multiple objects of the same model in a form? Something like<br /><br />Rendered view form:<br /><br />CActiveForm {<br /> $a = new Class1;<br /> $b = new Class1;<br /><br /> ...<br /> echo $form->textField($a, 'field1');<br /> ...<br /> echo $form->textField($b, 'field1');<br /> ...<br />}<br /><br />I still couldnt find out a way to do itDanielhttps://www.blogger.com/profile/16820540687849809976noreply@blogger.comtag:blogger.com,1999:blog-7303829017133230496.post-66481681141738219722010-04-12T13:38:05.316-04:002010-04-12T13:38:05.316-04:00I did read that one and found it quite helpful! My...I did read that one and found it quite helpful! My confusion came in with the ajax validation and realizing that validate actually will convert a single element into an array for processing if you don't pass in an array.<br /><br />Thanks for your feedback btw =) Much appreciate the insights!Dana Lutherhttps://www.blogger.com/profile/07289965994216523233noreply@blogger.comtag:blogger.com,1999:blog-7303829017133230496.post-49605406971091140272010-03-31T17:11:48.198-04:002010-03-31T17:11:48.198-04:00I don't know if you read this yet:
http://www...I don't know if you read this yet:<br /><br />http://www.yiiframework.com/doc/cookbook/19/Unknownhttps://www.blogger.com/profile/02383314521242445961noreply@blogger.com