submitting checkboxes as array

Hi,

my question is about how can I handle array as parameter (generatated by a form) in controller.

I have a form:




...

<input name="id" type="hidden" value="345"/><br/>

<lable>Val 1</label><input name="arr[]" type="checkbox" value="700"/><br/>

<lable>Val 2</label><input name="arr[]" type="checkbox" value="800"/><br/>

<lable>Val 3</label><input name="arr[]" type="checkbox" value="900"/><br/>

...



The form’s ‘action’ parameter is a conrollers function:


public function actionSaveMyForm($id, $arr) {

		print_r($arr); // it doesn't work: CHttpException: You are not authorized to perform this action

	}

My opinion: this error is because of $arr parameter: yii waits for ‘arr’ in URL (form method is GET), but the URL is: …index.php?r=MyController/SaveMyForm&id=7&arr[]=700&arr[]=800

How can I get the whole $arr array in the controllers function?

Thanks for any help

check the accessRules

yangmis is right. This error only shows if you forgot to define your action in the accessRules() function of your controller. Just add ‘saveMyForm’ (without the action prefix) to one of the rules and it should work as expected.

Thank you, guys, but the problem is not this. I have already added it to accessRules, and if I type this to the browser:


index.php?r=MyController/SaveMyForm&id=7&arr=700

It works. Thats why I think it is because of the array-parameter.