Custom Attributes And Multi-Model Validation

I have a form, using which user can submit a post. For example post (model Post) have title, text and list of tags. Tags (model Tag) are stored in a different table and saved to database using another model.

When user submits a form it goes through validation process, but I can’t save tags for the post before post itself becomes validated and saved to database.

How do I resolve this issue, so list of tags are saved when user submits a post?

visit:

http://www.yiiframework.com/extension/multimodelform/ or

Define a custom field in model and define rule for it as other fields/column in tables

and make sure

if(isset($_POST[‘ajax’]) && $_POST[‘ajax’]===‘my-form’)

	{


		echo CActiveForm::validate($model);


		Yii::app()->end();


	}

in controller