2amigos / yii2-date-picker-widget

Bootstrap DatePicker Widget for Yii2
https://2amigos.us
Other
130 stars 77 forks source link

Dependant Datepickers #36

Open ghost opened 8 years ago

ghost commented 8 years ago

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
    ]
]);
?>
tonydspaniard commented 7 years ago

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)