我想显示大于当前日期的日期 在ValidFrom中,在ValidUpto字段中的日期大于ValidFrom但无法显示。我想在日期选择器中隐藏以前的日期。
我的代码如下。
echo DatePicker::widget([
'model' => $model,
'attribute' => 'ValidFrom',
'attribute2' => 'ValidUpto',
'options' => ['placeholder' => 'valid from',
],
'options2' => ['placeholder' => 'valid to'],
'type' => DatePicker::TYPE_RANGE,
'form' => $form,
'pluginOptions' => [
'format' => 'yyyy-mm-dd',
'autoclose' => true,
],
]);
答案 0 :(得分:0)
为日期选择器添加id属性:
echo DatePicker::widget([
'id'=>'mydatepicker',
'model' => $model,
'attribute' => 'ValidFrom',
'attribute2' => 'ValidUpto',
'options' => ['placeholder' => 'valid from',
],
'options2' => ['placeholder' => 'valid to'],
'type' => DatePicker::TYPE_RANGE,
'form' => $form,
'pluginOptions' => [
'format' => 'yyyy-mm-dd',
'autoclose' => true,
],
]);
将minDate设置为视图文件中的日期选择器:
<?
$script = <<< JS
$( "#mydatepicker").datepicker({dateFormat: "yyyy-mm-dd", minDate: 0});
JS;
$this->registerJs($script, View::POS_END);
?>