We've moved discussions to Discord

Tip - How to enable a date picker in the template

Dan Tappin
FYI there is date picker in the administrate section of the template.  To add it to the rest of your app add something like this to your main application.js file (code copied from the administrate/components/date_time_picker.js file):

import 'administrate/components/date_time_picker'
import flatpickr from 'flatpickr'

function bindDatePicker() {
  [...document.querySelectorAll('[data-type="date"]')].forEach((time) => {
    flatpickr(time, {
      enableTime: false,
      altInput: true,
      altFormat: 'F j, Y',
      dateFormat: 'Y-m-d' // H:i
    })
  });

}

Just a suggestion to  and add this to the main app not just the admin section.
LarryTu
Thanks a lot!

In addition, you need to change the form tag from <datetime_select> to <datetime_field>

something like this:

<%= form.datetime_field :start_at, class: "form-control" %>
Dan Tappin
FYI there is date picker in the administrate section of the template.  To add it to the rest of your app add something like this to your main application.js file (code copied from the administrate/components/date_time_picker.js file):

import 'administrate/components/date_time_picker'
import flatpickr from 'flatpickr'

function bindDatePicker() {
  [...document.querySelectorAll('[data-type="date"]')].forEach((time) => {
    flatpickr(time, {
      enableTime: false,
      altInput: true,
      altFormat: 'F j, Y',
      dateFormat: 'Y-m-d' // H:i
    })
  });

}

Just a suggestion to  and add this to the main app not just the admin section.
LarryTu
Thanks a lot!

In addition, you need to change the form tag from <datetime_select> to <datetime_field>

something like this:

<%= form.datetime_field :start_at, class: "form-control" %>
Notifications
You’re not receiving notifications from this thread.
© 2023 Jumpstart Pro by GoRails, LLC