相关的日期选择器

时间:2016-09-20 04:25:20

标签: yii2 bootstrap-datepicker

我有两个日期字段,最长日期不能在初始日期之前,所以我禁用了pickupMaxDate,并在onChange()中再次启用了它。在那里我需要将startDate参数设置为在第一个DatePicker

中选择的值

这就是我尝试过的:

<?=
$form->field($shipment, 'pickupDate')->widget(
        DatePicker::className(), [
    'clientOptions' => [
        'autoclose' => true,
        'todayHighlight' => true,
        'language' => 'es',
        'startDate' => '0d',
        'format' => 'dd-M-yyyy'
    ],
    'clientEvents' => [
        'change' => 'function (dateText, inst) {
            //-> WORKING
            $("#shipment-pickupdatemax").prop("disabled", false);

            //-> NOT WORKING
            var mindate = $(this).datepicker("getDate"); //-> PRINTS (Wed Sep 28 2016 00:00:00 GMT-0600 (CST))
            $("#shipment-pickupdatemax").datepicker("option", "startDate", mindate);
        }',
    ],
]);
?>
<?=
$form->field($shipment, 'pickupDateMax')->widget(
        DatePicker::className(), [
    'clientOptions' => [
        'autoclose' => true,
        'todayHighlight' => true,
        'language' => 'es',
        'startDate' => '0d',
        'format' => 'dd-M-yyyy'
    ],
    'options' => [
        'disabled' => true
    ]
]);
?>

我如何实现这一目标?

0 个答案:

没有答案