Skip to content

Instantly share code, notes, and snippets.

@init90
Created December 22, 2016 15:38
Show Gist options
  • Select an option

  • Save init90/fa311169a66c4d62e99f4e91fc12d49c to your computer and use it in GitHub Desktop.

Select an option

Save init90/fa311169a66c4d62e99f4e91fc12d49c to your computer and use it in GitHub Desktop.
drupal 7, add date field with popup calendar to custom form.
$form['startdate'] = array(
'#type' => 'date_popup',
'#title' => t('Lesson start date'),
'#timepicker' => 'timepicker',
'#timepicker_options' => array(
'rows' => 6,
'minutes' => array(
'starts' => 0,
'ends' => 56,
'interval' => 4,
),
'showCloseButton' => TRUE,
'closeButtonText' => t('Close'),
),
'#required' => TRUE,
'#date_label_position' => 'above',
'#default_value' => isset($lesson->startdate) ? date('Y-m-d H:i', $lesson->startdate) : '',
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment