yii2-date-picker-widget
yii2-date-picker-widget copied to clipboard
Dependant Datepickers
I need to set a pickupDate and pickupDateMax, the maximum date cannot be earlier than the initial date, i disabled the maxDate and should be set until pickupDate has some value, any ideas how to accomplish that?
This are my fields
<?=
$form->field($shipment, 'pickupDate')->widget(
DatePicker::className(), [
'clientOptions' => [
'autoclose' => true,
'todayHighlight' => true,
'language' => 'es',
'startDate' => '0d',
'format' => 'dd-M-yyyy'
]
]);
?>
<?=
$form->field($shipment, 'pickupDateMax')->widget(
DatePicker::className(), [
'clientOptions' => [
'autoclose' => true,
'todayHighlight' => true,
'language' => 'es',
'startDate' => '0d',
'format' => 'dd-M-yyyy'
],
'options' => [
'disabled' => true
]
]);
?>
I would use the events provided and then ensure with correspondent methods (ie setStartDate, setEndDate, etc...) to make sure the other dependent date is within the correct range (reference: http://bootstrap-datepicker.readthedocs.io/en/latest/events.html#changedate)