Other filters not working when filtering date range in CGridView

Hi All,

I’ve been working on getting a date range filter working on a record database i have.

I was finally able to get it working(with some modifications) following this Tutorial.

Everything was created with Gii with some slight mods.

I can sort by the date range now but the problem is when i try to use other filters in combination with this. They don’t work. I can either use the normal filters set up.

The date range filters datef

Here’s the search() method in my model:

public function search()


		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;







		if(!empty($this->from_date) && empty($this->to_date)){

			$criteria->condition = "DATE(date_added) >= '$this->from_date'";  // date is database date column field

		}elseif(!empty($this->to_date) && empty($this->from_date)){

			$criteria->condition = "DATE(date_added) <= '$this->to_date'";

		}elseif(!empty($this->to_date) && !empty($this->from_date)){

			$criteria->condition = "DATE(date_added)  >= '$this->from_date' and DATE(date_added) <= '$this->to_date'";


		return new CActiveDataProvider($this, array(




Here’s my Controller:

	public function actionViewall()


		$model=new Notes('search');

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









My CGridView:

$this->widget('zii.widgets.grid.CGridView', array(




	'htmlOptions'=>array('style'=>'cursor: pointer;'),

	'selectionChanged'=>"function(id){window.location='" . Yii::app()->urlManager->createUrl('', array('notes'=>'')) . "/' + $.fn.yiiGridView.getSelection(id);}",







			'filter'=>'From' . CHtml::activeTextField($model,'from_date') . 'To' . CHtml::activeTextField($model,'to_date'),




			'value'=>'strlen($data->note)>50 ? substr($data->note,0,50) . " . . ." : $data->note',






			'filter' => CHtml::listData(Tags::model()->findAll(), 'id', 'tag'),







Any Thoughs?



Your question is about yii1, but this is the yii2 forum…