Hi
Than do like below
Controller file code
public function actionIndex()
{
$model=new University('search');
$model->unsetAttributes(); // clear any default values
$show_cont = 0;
if(isset($_GET['University'])){
$model->attributes=$_GET['University'];
$show_cont = 1;
}
//send model object for search
$this->render('index',array(
'dataProvider'=>$model->search(),
'model'=>$model,
'show_cont' => $show_cont,
));
}
View File Code
//search
Yii::app()->clientScript->registerScript(‘search’, "
$(’.search-button’).click(function(){
$('.search-form').toggle();
return false;
});
$(’.search-form form’).submit(function(){
$.fn.yiiListView.update('universitylistview', {
//this entire js section is taken from admin.php. w/only this line diff
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Universities</h1>
<div><br>
<?php echo CHtml::link(‘Search University’,’#’,array(‘class’=>‘search-button btn btn-primary’,‘data-title’=>‘Search’, ‘data-content’=>‘You can search your university either by its full name or partial name.’, ‘rel’=>‘popover’)); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial(’_search’,array(
'model'=>$model,
)); ?>
</div>
<?php if($show_cont == 1){ $this->widget(‘zii.widgets.CListView’, array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'id'=>'universitylistview',
)); } ?>
In this case whenever you will search than show a list otherwise only Search area show you.
Thanks