yii2-date-picker-widget icon indicating copy to clipboard operation
yii2-date-picker-widget copied to clipboard

Dependant Datepickers

Open ghost opened this issue 9 years ago • 1 comments

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
    ]
]);
?>

ghost avatar Sep 20 '16 03:09 ghost

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)

tonydspaniard avatar Oct 19 '16 14:10 tonydspaniard