Im sorry.
I am trying to create a daterange searchfield and this is what i have come up with:
In my model:
public $date_first;
public $date_last;
public function rules()
{
return array(
array('..., date_first, date_last', 'safe', 'on'=>'search'),
);
}
public function search()
{
$criteria=new CDbCriteria;
$criteria->compare( ... );
if((isset($this->date_first) && trim($this->date_first) != "") && (isset($this->date_last) && trim($this->date_last) != ""))
$criteria->addBetweenCondition('from_date', ''.$this->date_first.'', ''.$this->date_last.'');
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
And this is in the _search view(datepicker):
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
// 'model'=>$model,
'name' => 'Event[date_first]',
'language' => 'id',
'value' => $model->date_first,
// additional javascript options for the date picker plugin
'options'=>array(
'showAnim'=>'fold',
'dateFormat'=>'yy-mm-dd',
'changeMonth' => 'true',
'changeYear'=>'true',
'constrainInput' => 'false',
),
'htmlOptions'=>array(
'style'=>'height:20px;width:70px;',
),
),true) ;
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
// 'model'=>$model,
'name' => 'Event[date_last]',
'language' => 'id',
'value' => $model->date_last,
// additional javascript options for the date picker plugin
'options'=>array(
'showAnim'=>'fold',
'dateFormat'=>'yy-mm-dd',
'changeMonth' => 'true',
'changeYear'=>'true',
'constrainInput' => 'false',
),
'htmlOptions'=>array(
'style'=>'height:20px;width:70px',
),
),true);
This does not provide an error but the search functionality doesn’t work.
Any ideas?