CGridView and search inside a module


I’ve been struggling with what I now identify as a bug : in certain circumstances the ajax Search box which is included in the admin page created by Gii CRUD, is not working properly.

Here is a setp-by-step to reproduce :

Pre-requisite : a database connection, a table in this DB, and let’s say 20 rows in this table (at least more than 10)

Yii 1.1.7

  • create a fresh yii application (command webapp)
  • modify the webapp config[list]
  • enable Gii module
  • configure DB component
  • enable urlManager with ‘urlFormat’ set to ‘path’ (just uncomment the default urlManager initialisation bloc created automatically by the webapp command

[]go to the Gii page (first login as admin/admin)[]create a model for your table[]create a module that we will call mod[]modify the configuration and declare this new module[*]create a CRUD for your model

  • we want to create this CRUD inside an ‘admin’ folder, itself part of our mod module. The Controller ID should then be mod/admin/main (yes, my controller’s name is main)
  • check that the preview is ok, and click ‘generate’

[/list]We are done. Now let’s go to the ‘admin’ page inside our module. The route is ‘index.php/mod/admin/main’ because remember that we activated the url path format.

We land on the default action that displays a list of all items currently stored on the DB. Now let’s click on the ‘manage XXXX’ link to see the CGridView. As we have a lot of items in our table, several pages should be available. Now careful :

  • open the search box and perform a search that will return all items. For instance, if you have a ID field, you can set the condition ‘<> anything’ … all items will be returned
  • navigate to the second page
  • perform the very same search as before

[color="#FF0000"]BOUM ![/color]

(see screenshot)

Let’s notice that I didn’t write any piece of code, but just made some very basic configuration… and it is easely reproductible (althought it took me a while to isolate this scenario)

The error happens only if :

[list=1][]we are doing this from within a module[]the urlFormat is set to path[/list]By taking a look at the HTTP Request Header, I could se that the RequestURL is messed up and I assume that Yii fails to parse query string parameters.



I’d like to know what URL rules you have defined for your application.

(I guess it might only be a problem with the rules for the urlManager.)

Hi softark,

first I was using the url rules automatically created by Yii when it generates the CRUD. Of course I’ve also disabled all URL rules and the result is exactly the same.


I tried to reproduce your case.

Though I couldn’t get the same symptom, but yes, I noticed some malfunction in the CGridView ajax search.

But I’d like to ask you to try the following configuration.

// application components














The configuration above worked fine for me. It solved the problem.

As you may see, I added 3 new rules to the default ones that yii has provided.

New ones are for the controllers in some sub directory in some module.

thanks for spending time working on that !

So what do you think ? is it a bug or not ? I mean for me, being obliged to define URL rules to make things work correctly is …humm let’s say, “not convinient”.

… but maybe I missed the tutorial chapter where this is explained.


So does it work right for you too?

I agree with you that it’s not very convenient, and there are no explanation on this matter in the tutorial AFAIK.

I’m afraid there are so many of us suffering this “rules for module” problem.

yes, it fixes the problem… but anyway, as I don’t want to run into this kind of issue anymore, I will go back to standard URL format.

Thanks for your help softark ! ;)