Create New Data In One Form And Save Into Multi Model Class (Table)

Hi everybody.

I want to save product details, which will keep all older information and create new information revision when update product details. For that purpose, I created two table that called : product & product_detail like the following:


       + id

       + vid  // current version of Product Detail

       + status // of Product


       + id

       + pid // product id , refer to

       + name 

       + details


In this way, we have two model Class called Product, ProductDetail in Yii. By using Gii we have separate controller, form, and view.

My question is : "What’s the best way to make a form for user to create new product and detail information and save into two table in one request in Yii? "

When update, we load the information in two table, after that we need update vid in Product and create new record in Product_detail when User submit.

I’m new in Yii, Thank for your time !

Update: I found this tutorial , but is there any better way ? because my two table have the relation.

I resolved this by using relation() in model class. It better than declare to model class in one form for handling.

Thanks !