Hey there –
I love this extension and its functionalities, though I’m hitting a wall with TbGridView. Maybe this is something people have already discovered/worked through, but I’m having trouble with the filtering function.
Some context: I have a referral model with the following (standard, Gii-created) search() function.
public function search()
{
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('referName',$this->referName,true);
$criteria->compare('route',$this->route,true);
$criteria->compare('publisher',$this->publisher,true);
$criteria->compare('channel',$this->channel,true);
$criteria->compare('active',$this->active,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
In my ReferralController.php, I have the following index() function, which creates the data provider from the Referral model. It also passes a referral param for potential filtering.
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Referral');
$this->render('index',array(
'dataProvider'=>$dataProvider,
'referral'=> New referral(),
));
}
The following code will generate a nice, pretty gridview with search fields… that don’t work.
<?php $this->widget('bootstrap.widgets.TbGridView', array(
'type'=>'striped bordered condensed',
'dataProvider'=>$dataProvider,
'template'=>"{items}",
'filter'=>$referral,
'columns'=>array(
array('name'=>'id', 'header'=>'#'),
array('name'=>'referName', 'header'=>'Referral Name'),
array('name'=>'route', 'header'=>'Redirect To'),
array('name'=>'publisher', 'header'=>'Publisher'),
array('name'=>'channel', 'header'=>'Channel'),
array('name'=>'active', 'header'=>'Active'),
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
'htmlOptions'=>array('style'=>'width: 50px'),
),
),
)); ?>
If I change ‘filter’=>$referral to ‘filter’=>$referral->search() as most the examples suggest, I get the following error:
CActiveDataProvider and its behaviors do not have a method or closure named "getValidators".
I’ve attached a copy of the stack trace if anyone has any ideas. I have a feeling this is an obvious mistake, but I’m just not seeing it.
Any help would be greatly appreciated–