Halo, I want to display the results of the search form in my admin page after the form is submitted and the grid view is filtered. How can i do that? Any help would be appreciated, Thanks!!
this is my controller action
public function actionAdmin()
{
$this->layout = 'column3';
$model=new Payment('search');
$model->unsetAttributes(); // clear any default values
$results = 'Marcos';
if(isset($_POST['Payment']))
{
if(!empty($_POST['from_date']))
{
$model->from_date = $_POST['from_date'];
$results+=$model->from_date;
}
if(!empty($_POST['to_date']))
{
$model->to_date = $_POST['to_date'];
}
if(!empty($_POST['Payment']['first_name']))
{
$model->first_name = $_POST['Payment']['first_name'];
}
if(!empty($_POST['Payment']['last_name']))
{
$model->last_name = $_POST['Payment']['last_name'];
}
}
$this->render('admin',array(
'model'=>$model,
'results'=>$results,
));
}
And this is my admin page
<?php
/* @var $this PaymentController */
/* @var $model Payment */
$this->breadcrumbs=array(
'Payments'=>array('index'),
'Manage',
);
$this->menu = array(
array('label'=>'All','url'=>array('admin')),
array('label'=>'M-PESA','url'=>array('admin'))
);
Yii::app()->clientScript->registerScript('search', "
$('.search-form form').submit(function(){
$('#payment-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Manage Payments</h1>
<?php
//if(!empty($_POST['Payment']['first_name']))
echo $results;
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'payment-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'ajaxType'=>'post',
'columns'=>array(
array(
'name'=>'service_name',
'filter'=>false
),
//'business_number',
array(
'name'=>'transaction_reference',
'filter'=>false
),
array(
'name'=>'internal_transaction_id',
'filter'=>false
),
array(
'name'=>'transaction_timestamp',
'value'=>'Yii::app()->dateFormatter->format("h:m a-d/MM/y",strtotime($data->transaction_timestamp))',
'htmlOptions'=>array('size'=>20),
'filter'=>FALSE
),
array(
'name'=>'transaction_type',
'filter'=>false
),
//
// 'account_number',
// 'sender_phone',
array(
'name'=>'first_name',
'filter'=>false
),
// 'middle_name',
array(
'name'=>'last_name',
'filter'=>false
),
array(
'name'=>'amount',
'value'=>'Yii::app()->format->number(abs($data->amount))',
'filter'=>FALSE
),
// 'currency',
// 'signature',
// 'id',
array(
'class'=>'CButtonColumn',
),
),
)); ?>