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(
'id'=>'whatever-grid',
'dataProvider'=>$model->myScope()->search(),
'filter'=>$model,
'columns'=>array(
'id',
...
array(
'class'=>'CButtonColumn',
),
),
)); ?>
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->compare('id',$this->id);
........
$criteria->mergeWith($this->getDbCriteria()); //This is the new line
return new CActiveDataProvider(get_class($this),
array(
'criteria'=>$criteria,
)
);
}
Scopes now work with searches right out of the box. Any thoughts?