phpajaxyiiyii-chtml

Yii CHtml::ajaxSubmitButton always submits data in POST method


I came across this problem when I used CHtml::ajaxSubmitButton to submit some of the data as a GET method. No Matter what i try, It always submits data as a POST method.

Anything that I might be doing wrong? Here's my code.

echo CHtml::beginForm(array('shoppingCart/addItem','GET')); 
echo CHtml::textField('qty', 1, array('size' => 3));
echo CHtml::hiddenField('product_id', $model->product_id); echo CHtml::ajaxSubmitButton('submit',          
                array('shoppingCart/addItem'), 
                array(
                        'type'=>'GET',
                        //'data' => array()),
                ));

echo CHtml::endForm();

Solution

  • That is by design. You can use CHtml::ajaxButton instead:

    CHtml::ajaxButton('My Label','controller/action',array(
                'type'=>'GET',
            ), array(
                'type'=>'submit',
            );