I installed the Date Picker module, which works fine. This is what appears when I add the datepicker element to the form.


This is the code I use to add the datepicker element.

$form['date'] = array(
  '#title' => t('Select your birthdate'),
  '#type' => 'datepicker',
  '#date_format' => 'd/m/Y',
  '#date_year_range' => '-100:+0',
  '#default_value' => date("Y-m-d H:i:s", time()),

I want to display a text field; when it has the focus, the calendar should be shown.

How should I change the code to make it possible?


1 Answer 1


Have you tried using DatePicker inline module?

From module page:

This module permits inline rendering of date's popup widget. That is, it display the datepicker embedded in the page instead of in an overlay.

It integrates with field API, form API and views exposed filters (via date_views).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.