ressaince
(Bob Hartanto)
January 13, 2011, 6:11am
1
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
ressaince
(Bob Hartanto)
January 13, 2011, 12:08pm
3
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[]’?
zaccaria
(Matteo Falsitta)
January 13, 2011, 2:09pm
4
You should collect a tabular input.
Take a look at the guide here.
ressaince
(Bob Hartanto)
January 14, 2011, 12:21am
5
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
ressaince
(Bob Hartanto)
January 14, 2011, 4:40pm
6
aha…i have solved this problem…
thanks master for your guide
fouss
(Jsfousseni)
January 24, 2011, 11:52am
7
Can you share How you did that?