code model :
public function search() {
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id, true);
$criteria->compare('email', $this->email, true);
$criteria->compare('city_id', $this->city_id, true);
$criteria->compare('secret', $this->secret, true);
//$criteria->addSearchCondition('email','linux');
$criteria->order = 'id DESC';
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
'pagination' => array(
'pagesize' => 15,
)
));
}
code controller :
/**
* Lists all models.
*/
public function actionIndex() {
$model = new Subscribe('search');
$model->unsetAttributes(); // clear any default values
if (isset($_GET['Subscribe']))
$model->attributes = $_GET['Subscribe'];
$this->render('admin', array(
'model' => $model,
));
}
codel view :
<?php
$this->breadcrumbs = array(
'Subscribes' => array('index'),
'Manage',
);
$this->menu = array(
array('label' => 'List Subscribe', 'url' => array('index')),
array('label' => 'Create Subscribe', 'url' => array('create')),
);
Yii::app()->clientScript->registerScript(‘search’, "
$(’.search-button’).click(function(){
$('.search-form').toggle();
return false;
});
$(’.search-form form’).submit(function(){
$.fn.yiiGridView.update('product-grid', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1 style="height: 10px;"></h1>
<?php echo CHtml::link(‘Advanced Search’, ‘#’, array(‘class’ => ‘search-button’)); ?>
<div class="search-form" style="display:none">
<?php
$this->renderPartial('_search', array(
'model' => $model,
));
?>
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'news-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
array(
'name' => 'id',
'value' => '$data->id',
'htmlOptions' => array('style' => 'width: 40px; text-align: center;'),
),
array(
'name' => 'email',
'value' => '$data->email',
'htmlOptions' => array('style' => 'width: 40px; text-align: center;'),
),
array(
'name' => 'secret',
'value' => '$data->secret',
'htmlOptions' => array('style' => 'width: 40px; text-align: center;'),
),
array(
'class' => 'CButtonColumn',
'htmlOptions' => array('style' => 'text-align: center; width: 55px;'),
),
),
));
?>
and reviews
them I input data and enter not workiing !
Bro can help me !!