Passing parameters to actionDelete

Hi,

I am passing parameters to actionDelete function. Could you please help me how to retrieve it?

Changed CButtonColumn to

array(

  'class'=>'CButtonColumn',


  'template'=>'{update}{delete}',


  'buttons'=>array


      (


     'delete' => array


        (


               'url'=>'Yii::app()->createUrl("answers/delete",                                                        array("id"=>$data->id,"qid"=>$data->question_id,"oid"=>$data->ordering))',


        ),


		        


    ),

),

actionDelete function like

public function actionDelete($id)

{

}

I need to retrieve qid and oid values in actionDelete function. I have tried like public function actionDelete($id,$qid,$oid) but it is not working.

Could you please help me how to retrieve it?

Thanks in Advance.

Thanks & Regards,

Gangadhar

What is in your $_REQUEST ?

I didn’t get any request parameters. The action is working through Ajax.

Then use firebug for debug your post requests.

If you use the default delete button… set the deleteButtonUrl propery - http://www.yiiframework.com/doc/api/1.1/CButtonColumn#deleteButtonUrl-detail

I am using default delete button. I have tried like

array(

‘class’=>‘CButtonColumn’,

‘template’=>’{update}{delete}’,

‘deleteButtonUrl’=>‘Yii::app()->createUrl(“answers/delete”, array(“aid”=>$data->id,“qid”=>$data->question_id,“oid”=>$data->ordering))’,

),

But it is still not working.

NOTE: when you post code please use the code button <>… or type [ code] your code [ /code] (without spaces)… so that your code is more readable

Just noticed that you use Yii::app()->createUrl()… that does not exists and it fires an error… you need to use Yii::app()->controller->createUrl(…)

Thanks mdomba. I am new to yii. I will your instructions.

I have tried like




'deleteButtonUrl'=>'Yii::app()->controller->createUrl("answers/delete", array("aid"=>$data->id,"qid"=>$data->question_id,"oid"=>$data->ordering))',



But it is still not working. It gives error "Your request is invalid.".

Check your actionDelete() parameter names… they should be the same as the one you are sending here…

So it should be


public function actionDelete($aid,$qid,$oid)

If you have for example $id instead of $aid like:


public function actionDelete($id,$qid,$oid)

Then you would get the error "Your request is invalid"

Thanks mdomba…

Finally it is working.