Question

When you create an ajax button like

echo CHtml::ajaxSubmitButton(
    'Submit request',
    array('logInOfficeEmp/update&id='.$model->id),
    array(
        'replace'=>'#req_res02',
        array('id' => 'inside_popup') // how to retrieve this
    )
);

How to retrieve the ID in the controller, note that you get to know it's ajax or not using Yii::app()->request->isAjaxRequest()

Was it helpful?

Solution

Pass it as follows:

<?= CHtml::ajaxButton('Click', $this->createUrl('path/here', array('myparam' => 'test)), array('success' => 'js:function(){alert("test");}'), array('class' => 'cssclasses'))?>

It will then be available in $_POST['myparam']

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