Published on

How to change default 'No result found' text in Yii framework

Authors
  • avatar
    Name
    Bal Singh
    Twitter

Some time there is need to change the default "No result found" text by your own text, to provide more deep information to the front user. So in Yii framework we can set our custom text message in CGridList and CListView by simply set the value of "emptyText" property. For example to show "We have not found anything related to your query" instead of "No result found" text, see code below

$this->widget('zii.widgets.CListView', 
    array( 
        'dataProvider' => $dataProvider, 
        'itemView' => '/myView/_view', 
        **'emptyText' => 'We have not found anything related to your query.'** 
    )
); 

same in CGridList

$this->widget('zii.widgets.grid.CGridView',
    array( 
        'id'=>'my-grid', 
        'dataProvider'=>$model->search(), 
        'filter'=>$model,
        **'emptyText' => 'We have not found anything related to your query.'** '
        columns'=>array( 'id', 'title', )
    );