Action Parameters

I have a controller with actions.

I want to pass parameters to the actions via url


The param is just going to be a number or short string.

If I declare an action in the controller:

public function actionMyaction( $id )

Yii hands me the param nicely,

But if someone does


without a parameter I get a 404.

What’s the most Yii appropriate and graceful way to route that to a particular view rather than it ending up in a 404?

At first I thought invalidActionParams but I don’t understand the very brief description given on the docs page for that function.

Hi Phil

check this

public function actionMyaction($id=null) {

if ($id==null) {

//code without id param

} else {

//code with id param