How To Save Dropdown Value In Cgridview To Database?

I made a dropdown in Cgridview, my problem is how can i save the value to database using a button?

5567

Screenshot from 2014-05-15 16:04:55.png

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(); 


?>



More links for you

http://www.yiiframework.com/wiki/658/update-cgridview-row-separately-using-ajax-request/

http://www.yiiframework.com/wiki/353/working-with-cgridview-in-admin-panel/#hh1

Thank you :) I have to study this first :)