Meteor-Community-Packages / meteor-autoform-bs-datepicker

Custom "bootstrap-datepicker" input type for AutoForm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reactively setting minDate of a datepicker based on the value of another

coniel opened this issue · comments

I need a pair of date inputs to select a date range. The end date should obviously be after the start date. I can validate that using a custom validation method, but how would I go about making the minDate of the end date field be equal to the value of the start date field?

I tried the following, but it doesn't work (I get: Object # has no method 'field'), I guess the "field" method is only available in the custom validation function.

afFieldInput: {
    datePickerOptions: {
        minDate: this.field('startDate').value
    }
}

commented

+1

Agreed!

you can set the min value with the original.

xxx{
type:date,
min: new Date(moment().add(1, 'days').startOf('day')),
}
or just use min:new Date()

however, there still display today for selection but alert for choosing

Closing old issues. This could probably be done using a min helper in the template, based on reactive AutoForm.getFieldValue on the start field.