CGridView and Date

Hello!

Please, I need help.

I want to create the date filter in CGridView.

from, till.

I don’t know how to force CGridView to filter date.

I have already created fields for input of filters. Also has created it jquery a calendar.

My form:


<form action="" enctype="multipart/form-data" method="get">

<div style="text-align:center">

 from

<?php

	echo CHtml::activeTextField($model, 'date[from]', array(

        'value'=>date("j.m.Y"),

        'onfocus'=>'this.select();lcs(this)',

        'onclick'=>'event.cancelBubble=true;this.select();lcs(this)',

        

    )); 

?>

 till

<?php

	echo CHtml::activeTextField($model, 'date[till]', array(

        'value'=>date("j.m.Y"),

        'onfocus'=>'this.select();lcs(this)',

        'onclick'=>'event.cancelBubble=true;this.select();lcs(this)',

        

    ));

?>

	<input type="submit" class="make_filter" name="filterBtn" value="filter" />

	</div><br />

My Controller:


	

	public function actionIndex($id = false)

	{

        $model=new User('search');

		$model->unsetAttributes();  // clear any default values

        

           if (empty ($_GET['User'])) { if (is_numeric($id)) {$model->company_id = $id;} } 

           

		if(isset($_GET['User']))

        {

            

            $_GET['User']['date']['from'] = H::unix_time($_GET['User']['date']['from']);

            $_GET['User']['date']['till'] = H::unix_time($_GET['User']['date']['till']);

			$model->attributes=$_GET['User'];

            print_r ($_GET['User']);

            

        }    

                //print_r($model);

        $this->render('admin',array(

			'model'=>$model,

		));

	}

in my model


public function search()

    {

//////////.........

        

        if(isset($this->date['from']) && isset($this->date['from']))

        {

            $criteria->compare('date', '>='.$this->date['from']); 

            $criteria->compare('date', '<='.$this->date['till']);

        }

       

        return new CActiveDataProvider($this, array(

            'criteria'=>$criteria,

            'pagination' => array ('pageSize' => 100),

        ));

    } 

Why it does not work? I do not understand how to force it to work.

Hi Kuklovod and welcome!

Did you happen to see this?

It is a well thought out implementation, unfortunately as you can see from my last post there I have not gotten it to work for me yet. Maybe it will fit for what you need or at least give a point to compare and t/s from. If you happen to know what my problem may be with it I would appreciate any help there also.