2amigos Daterangepicker 在 Yii2 中不工作
2amigos Daterangepicker is not working in Yii2
我需要按日期范围过滤 GridView
中的记录,例如:01-05-2015
到 09-05-2015
。
我正在尝试使用 this extension 中的 DateRangePicker
为此,但它不起作用:
<?= $form->field($model, 'created_at')->widget(DateRangePicker::className(), [
'attributeTo' => 'date_to',
'model' => $model, // best for correct client validation
'language' => 'en',
'clientOptions' => [
'autoclose' => true,
'format' => 'yyyy-m-dd'
],
]) ?>
如果我设置 start_date
和 end_date
,它应该显示在这些日期之间创建的记录。
终于有答案了,
$query->andFilterWhere(['between', 'createdat', $this->createdat, $this->created_at]);
我需要按日期范围过滤 GridView
中的记录,例如:01-05-2015
到 09-05-2015
。
我正在尝试使用 this extension 中的 DateRangePicker
为此,但它不起作用:
<?= $form->field($model, 'created_at')->widget(DateRangePicker::className(), [
'attributeTo' => 'date_to',
'model' => $model, // best for correct client validation
'language' => 'en',
'clientOptions' => [
'autoclose' => true,
'format' => 'yyyy-m-dd'
],
]) ?>
如果我设置 start_date
和 end_date
,它应该显示在这些日期之间创建的记录。
终于有答案了,
$query->andFilterWhere(['between', 'createdat', $this->createdat, $this->created_at]);