-
Notifications
You must be signed in to change notification settings - Fork 3
Month picker
Cliff Parnitzky edited this page Feb 15, 2023
·
3 revisions
To only have a month picker follow this instruction:
-
make a copy of the
form_calendarfield
template -
add the JavaScript after the
flatpickr.min.js
injection at the top of the template$GLOBALS['TL_JAVASCRIPT'][] = 'bundles/hofffcalendarfield/flatpickr/plugins/monthSelect/index.js';
-
add the CSS after the
flatpickr.min.css
injection at the top of the template$GLOBALS['TL_CSS'][] = 'bundles/hofffcalendarfield/flatpickr/plugins/monthSelect/style.css';
-
go to the flatpickr configuration section at the bottom of the template and add the following code below the
customConfiguration
part
altInput: true,
plugins: [
new monthSelectPlugin({
shorthand: true,
dateFormat: "d.m.Y",
altFormat: "F Y",
theme: "dark"
})
]
Explanation:
-
altInput: true
enables, that the selected date will be send in another format than it is displayed -
altFormat: "F Y"
displays the selected date with month and year (e.g. May 2022) -
dateFormat: "d.m.Y"
defines the format to send the selected date with (e.g. 01.05.2022)
All information about the month picker plugin can be found here: https://flatpickr.js.org/plugins/#monthselectplugin