insert to 2 table from 1 form(simple question)

i have a 2 table that have a relationship,




productDelivery:

id

order_no

deliver_order

order_date


and


productDelivery_detail

id

productDeliveryId (from productDelivery)

product_number

quantity

description.




so 1 order can have more than 1 product.

i have a dynamic form fields to handle that.

this is my ProductDeliveryController actionCreate()




public function actionCreate()

	{

		$model=new ProductDelivery;

                $model2=new ProductDeliveryDetail;

	//if(isset($_POST['ProductDelivery']))

            //{

		//	$model->attributes=$_POST['ProductDelivery'];

		//	if($model->save())

		//		$this->redirect(array('view','id'=>$model->id));

		//}


		$this->render('create',array(

			'model'=>$model,,'model2'=>$model2

		));

	}



that inactive code part is what i’m not really know how to do it.

can you help me?

because i’m newbie in the php programming specially mvc model programming

i’m sory for my bad english

hello,

read this wiki Here

thanks for your reply!!

that is what i need…thanks bro…

may i ask a question again?

how to collect the data of the dynamic field?

i use jquery to add more field…

in the view :

<?php echo textField($model2,‘product_number[]’,array(‘size’=>60…)

is it right to make it ‘product_number[]’?

You should collect a tabular input.

Take a look at the guide here.

thanks for your reply zaccaria…

in the guide there’s

:

<td><?php echo CHtml::activeTextField($item,"[$i]name"); ?></td>

i use jquery implementation from : http://www.9lessons.info/2010/04/jquery-duplicate-field-form-submit-with.html

my question is. how to assign $i ?

i can’t use foreach like in the guide i think…

i need to get how much textField in my form right? what the best way to do this?

correct me if im wrong

aha…i have solved this problem…

thanks master for your guide

Can you share How you did that?