How to get parameter in action by forward function.

I want to forward to another controller’s action.But now I cant pass parameters.

This is ok.


This will be wrong.


Could anybody give me some advice?

You are trying to do a redirect.

The forward function does not change the requested Url, but it just executes some code belonging to another controller/action.

But I don’t want to change the url.So I can’t use redirect.

You can add additional parameters to the $_GET array :)

Thank you very much!

I had this same issue but wanted to use the getController and Render method to pass the variables. From inspecting the CWebApplication source this is what I came up with.

$data = [mydatasomewhere];








Basically, this uses the CWebApplication instance to create a specified controller. If successful, then it populates new vars with the controller and actions. You then have a valid instance of the controller you want and can use it like you normally would. This looks like a better approach then adding params to the _GET array.

Interesting solution, though it would use more resources than simply appending to $_GET