Saving data from one form into 2 models 2nd model fails

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>

It may be necessary to do some debugging here (to check if saving process is successful or not). You can try to use something like:




if(!$meta->save())

  echo 'Something';



And there is getErrors() method to get error messages (if any).

thanks for the reply. I figure out that I was missing code to grab the value of the FK in model1 into a field in model2.