function datetime_form_node_form_alter

Implements hook_form_BASE_FORM_ID_alter() for node forms.

File

drupal/core/modules/datetime/datetime.module, line 1135
Field hooks to implement a simple datetime field.

Code

function datetime_form_node_form_alter(&$form, &$form_state, $form_id) {

  // Alter the 'Authored on' date to use datetime.
  $form['author']['date']['#type'] = 'datetime';
  $config = Drupal::config('system.date');
  $format = $config
    ->get('formats.html_date') . ' ' . $config
    ->get('formats.html_time');
  $form['author']['date']['#description'] = t('Format: %format. Leave blank to use the time of form submission.', array(
    '%format' => datetime_format_example($format),
  ));
  unset($form['author']['date']['#maxlength']);
}