Adrianna
(Rhea Uplb)
May 15, 2014, 8:11am
1
I made a dropdown in Cgridview, my problem is how can i save the value to database using a button?
5567
As you can see on the photo, I made a ‘Save’ Button below. What I want is after the user choose from the dropdown (even some are NULL) and click the save button, my database should now contain the choosed value from dropdown.
Thank you for those who can help me.
Hi,
It should be like this just for example
textfield instead of dropdown
<?php
echo CHtml::beginForm();
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
array(
'header'=>'Quantity',
'value'=>'CHTML::textField($data->id_product,$data->quantity,array(\'width\'=>20,\'maxlength\'=>3))',
'type'=>'raw',
'htmlOptions'=>array('width'=>'20px'),
),
array(
'class'=>'CLinkColumn',
'header'=>'Product Name',
'labelExpression'=>'$data->product->product_name',
'urlExpression'=>'Yii::app()->createUrl("product/view", array("id"=>$data->id_product))',
),
array(
'header'=>'Price',
'value'=>'($data->product->price)*($data->quantity)',
'htmlOptions'=>array('width'=>'40px'),
),
array(
'value'=>'CHTML::button(\'Remove\', array(\'submit\' => Yii::app()->createUrl("cart/remove", array("id"=>$data->id_product))))',
'type'=>'raw',
'htmlOptions'=>array('width'=>'40px'),
),
),
));
echo CHTML::button('Update cart', array('submit' => Yii::app()->createUrl("cart/update")));
echo CHTML::button('Checkout', array('submit' => Yii::app()->createUrl("order/getInfo")));
echo CHtml::endForm();
?>
Adrianna
(Rhea Uplb)
May 15, 2014, 8:36am
4
Thank you I have to study this first