Gii Code Generation -- model->search() update?

Would it be a good idea to change the way active record models are auto-generated so that the search function allows things to work with scopes? For instance, out of the box, the following code does not work like one would think (for example in the admin view of any given auto-generated crud)

<?php $this->widget('zii.widgets.grid.CGridView', array(











)); ?>

The scope is never applied and is replaced totally by the criteria generated in the search function of the model. However, if the auto-generated code inside the model were changed just slightly like this:

public function search()


		// Warning: Please modify the following code to remove attributes that

		// should not be searched.

		$criteria=new CDbCriteria;



		$criteria->mergeWith($this->getDbCriteria()); //This is the new line

		return new CActiveDataProvider(get_class($this), 






Scopes now work with searches right out of the box. Any thoughts?

I think that is a good idea.

Like that is possible to apply scope in the controller without passing the CDataProvider to the view.

Good idea, MadSkillsTisdale


This code in the SVN already allows you to use scopes. You can assign to CActiveDataProvider.model with something like Post::model()->published()