I’ve created a form with fields from two diferent models and followed the instructions in the wiki. everything appears to be fine with the exception of the second model data is never saved. The original view files were created using gii. Can someone point me in hte right direction?
Thanks
Controller
public function actionCreate()
{
$model=new AutoTestScript;
$meta=new AutoTestScriptMeta;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['AutoTestScript']) && isset($_POST['AutoTestScriptMeta']))
{
$model->attributes=$_POST['AutoTestScript'];
$meta->attributes=$_POST['AutoTestScriptMeta'];
if($model->save());
if($meta->save());
$this->redirect(array('admin','id'=>$model->id, $meta->id));
}
$this->render('create',array(
'model'=>$model,
'meta'=>$meta,
));
}
create.php snippit at end
<br>
<font size=2><b>Add Automated Test Script</b></font>
<br>
<br>
<?php echo $this->renderPartial(’_form’, array(‘model’=>$model, ‘meta’=>$meta )); ?>
Submit button from _form.php<tr>
<tr>
<td><?php echo CHtml::submitButton($model->isNewRecord ? ‘Create’ : ‘Save’); ?></td>