1

I'd like to have the jquery datepicker calendar always visible on a date element in my Drupal 8 form.

I see that this is possible to do by setting the datepicker to a div instead of an input.

However, since date elements of forms are declared like

$form['date'] = array(
    '#type' => 'date',
);

this doesn't seem like an option that the date element properties allow.

Is there a method of doing this that is compatible with Drupal forms?

  • Try using '#type' => 'date_popup', as per Using with date_popup Form API element. This worked for me in D7, hopefully it still works in D8. – No Sssweat Feb 22 '18 at 17:47
  • 1
    @NoSssweat thanks for the suggestion! unfortunately, it does not seem to work in D8 :( – saramm1 Feb 22 '18 at 18:36
  • The default datepicker is using the HTML5 datepicker element. If you want to use jQuery's datepicker, you would have to implement attaching this to your form. Would that be an option for you? – Stefanos Petrakis Feb 22 '18 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.