Question

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();
Was it helpful?

Solution 2

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

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

OTHER TIPS

Regarding to this document the value of type will be overwritten.

public static function ajaxSubmitButton($label,$url,$ajaxOptions=array(),$htmlOptions=array())
{
    $ajaxOptions['type']='POST';
    $htmlOptions['type']='submit';
    return self::ajaxButton($label,$url,$ajaxOptions,$htmlOptions);
}

So there is no way to use GET as long as you do not touch the core function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top