action parameter binding

Hi all…

I am trying to pass a string to ma action instead of an ID. but when i do that i get 400 ERROR.

here is my sample code…




public function actionAll($category)

	{ 

	echo $category;

        }

	

which is in members controller…

so my url is http://192.168.7.110/em/Members/All/Artist

as i said i get "Error 400 Your request is invalid." error.

I have referred to

but dint achieve it… only $id works… Please help…

hi

can you submit view file code ?

Thanks

This is not an view issue.

You are trying to pass text GET parameter in path style. This is possible, however default routing rules are matching only numeric "id" parameter.

In order to make your example working you have to add routing in your main.php config like this:




'<controller:\w+>/<cact:\w+>/<action:\w+>'=>'<controller>/<cact>',



You should also always use createUrl method - it will generate proper url no matter if you have routing rules defined or not (if not - the url will have form like this: http://192.168.7.110/em/Members/All?action=Artist.

After few minutes one more think comes to my mind - your parameter name “action” can be in conflict with default routing rule where ‘action’ actually points to controllers action. If above solution won’t work, try to change your param name.

@redguy… Well that worked for me… Thanks:) i should have checked it first only:)