I have an actionCreate in a controller, which renders the create.php view:
$inshopItemsList=new inShopItem(); //creates an instance of a model to populate the CGridView.
$this->render('create',array(
'model'=>$model,
'inshopItemsList'=>$inshopItemsList,
));
In the _form.php which is renderePartial in create.php view file I try to use CGridView the usual way:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'user-grid',
'dataProvider'=>$inshopItemsList->search(),
'filter'=>$inshopItemsList
...
but it returns an empty set. Record is returned only when I change this:
'dataProvider'=>$inshopItemsList->search(),
'filter'=>$inshopItemsList
with this:
'dataProvider'=>$inshopItemsList,
//'filter'=>new inShopItem(),
and in a controller:
$inshopItemsList=new inShopItem();
to:
$inshopItemsList = new CActiveDataProvider(inShopItem::model()->active()->with('frontImage'), array(
'pagination' => array (
'pageSize' => Yii::app()->user->getState('pageSize', 20),
),
));
I want to use all the benefits of the built in filtering features but I don’t now how. Please, help.
Search methods looks like this and works correct for a CGridView in another view file:
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('itemID',$this->itemID,false);
$criteria->compare('itemActive',$this->itemActive,true);
$criteria->compare('itemBasePrice',$this->itemBasePrice,false);
$criteria->compare('itemStockTotal',$this->itemStockTotal,false);
$criteria->compare('itemCode',$this->itemCode,true);
$criteria->compare('itemName',$this->itemName,true);
$criteria->compare('itemBrandID',$this->itemBrandID,true);
$criteria->compare('itemType',$this->itemType,true);
$criteria->compare('itemSetSize',$this->itemSetSize,true);
$criteria->compare('gender',$this->gender,true);
$criteria->compare('itemBackName',$this->itemBackName,true);
return new CActiveDataProvider(inShopItem::model()->active()->with('frontImage'), array(
'criteria'=>$criteria,
'pagination' => array (
'pageSize' => Yii::app()->user->getState('pageSize', 20),
),
));
}