Hi Everyone,
All i want to do is just able to filter using date on gridview / advanced search section. i have search for the answer and tried several method but unfortunately, the problem is still persist to me. i’m even not using between range of date scenario. the objective is simple so the user should be able to search on spesific date, and all data on that date should be displayed on the gridview.
here is the date widget on my search form :
<div class="row">
<?php echo $form->label($model,'tgl_surat_jalan'); ?>
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$model,
'attribute'=>'tgl_surat_jalan',
'value' => $model->tgl_surat_jalan,
// additional javascript options for the date picker plugin
'options'=>array(
'showAnim'=>'fold',
'dateFormat'=>'yy-mm-dd',
),
'htmlOptions'=>array(
//'style'=>'height:10px;',
'value'=>date('Y-m-d'),
),
)); ?>
</div>
and here is the search criteria on my model (as i point my dataProvider to $model->dibuat()) :
public function dibuat()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('kode',$this->kode,true);
$criteria->compare('mobil',$this->mobil,true);
$criteria->compare('no_rangka',$this->no_rangka,true);
$criteria->compare('no_mesin',$this->no_mesin,true);
$criteria->compare('warna_id',$this->warna_id,true);
$criteria->compare('dealer_id',$this->dealer_id,true);
$criteria->compare('asal',$this->asal,true);
$criteria->compare('tujuan',$this->tujuan);
$criteria->compare('ongkos',$this->ongkos,true);
$criteria->compare('harga',$this->harga,true);
$criteria->compare('keterangan',$this->keterangan,true);
//$criteria->compare('tgl_surat_jalan',$this->tgl_surat_jalan,true);
$criteria->compare('tgl_surat_jalan',CDateTimeParser::parse($this->tgl_surat_jalan, 'yyyy-MM-DD'),true);
$criteria->compare('status','Dibuat',true,'AND');
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
i’m able filter with the other attribute, but if i tried to filter using datefield then the search function is not working. am i missing something here? i’m just curious how search method work for datefield in yii.
Regards,
Razril