Need Help On How To Pass Multiple Parameters To An Action

Hi there,

could anybody give some advice on how to configure the action to accept multiple parameters? let’s say, the URL is something like this:

where params could be something like






I realized that my actual configuration only accepts one numeric parameter to be handled by

public function actionFoo ($int)



I appreciate your help

Found it in this comment of the controller section (action parameter binding) of the guide:

// $int is needed

// $cat is optional with default value

// $foo is optional with no default value

public function actionFoo ($int, $cat='default value if you need it', $foo=null)





but, how you build the url so the function accepts both paramaters?

i tried


and it dont works

many thanks for your help

Dear Friend

You have to create url in the following way



I will try this

many thanks for your help

Dear friend,

after chritsmas holidays we’re now working.

Could you please tellme whats wrong on this:

public function actionFoo ($int, $cmf=‘0’)



I build the link using


then the builded link is


when you click on this link you receive this error from yii

Error 400

Your request is invalid.

Could you please help me on what im doing wrong?

thanks in advance

  • do you use the controllerId (foo not fooController)?

     //wrong: Yii::app()->createUrl("fooController/foo",array("int"=>"1","cfm"=>"8")); 


  • you should find more information in the application.log file.

  • debug the request.

Dear Friend

Let us consider an example.

We have one controller TrialController.php in controller folder.

Then we have two views one.php and two.php in views/trial folder.



class TrialController extends Controller



       // action one renders view one and displays the link.

	public function actionOne()




	public function actionTwo($id,$name)


             //$id and $name are available inside the method.You can do whatever logic you can do with them

             //Here we are just passing them to the view.	








//You can also pass dynamic variable from form submission or database tables.

echo CHtml::link("click",array("trial/two","id"=>$id,"name"=>$name));

//Here CHtml::link calls CHtml::normalizeUrl and creates url from the second parameter.




echo "your id is :".$id;

echo "</br>";

echo "your name is :".$name;


I hope I helped a bit.


can you guys help me of how to set view to another view model? and configuring the controller? dunno how to set up things like that, newbie here, as in totally newbie :) thanks anyway