Hello,
I am using the Date Picker elements in Cornerstone Forms and I would like to know whether it is possible, using only Cornerstone settings, to disable some days of the week, for example Sundays only.
My goal is simple:
- keep the Date Picker in single mode
- prevent users from selecting Sunday
- keep all the native settings configured in the Cornerstone UI
What I tried:
- initializing Flatpickr with custom JavaScript
- using a selector on my field and adding a disable function for Sundays
Example:
document.addEventListener('DOMContentLoaded', function () {
if (typeof flatpickr !== "undefined") {
document.querySelectorAll(".notsundays").forEach(function(el) {
if (!el._flatpickr) {
flatpickr(el, {
mode: "single",
dateFormat: "Y-m-d",
disable: [
function(date) {
return date.getDay() === 0;
}
]
});
}
});
}
});
The problem is that as soon as I do this, it seems to override the settings already defined in Cornerstone for that field. So I lose the benefit of configuring the Date Picker directly in the builder.
My questions are:
- Is there a way to disable specific weekdays, such as Sundays, directly in Cornerstone, without custom JS?
- If not, is there a recommended way to extend the existing Date Picker / Flatpickr instance without replacing the Cornerstone configuration?
- More generally, is there an official method for adding Flatpickr options like disable while preserving the field settings made in the UI?
Thanks.