function system_date_time_lookup

Ajax callback; Returns the date for a given format string.

3 string references to 'system_date_time_lookup'
DateFormatAddForm::buildForm in drupal/core/modules/system/lib/Drupal/system/Form/DateFormatAddForm.php
Form constructor.
DateFormatEditForm::buildForm in drupal/core/modules/system/lib/Drupal/system/Form/DateFormatEditForm.php
Form constructor.
system_menu in drupal/core/modules/system/system.module
Implements hook_menu().

File

drupal/core/modules/system/system.admin.inc, line 1866
Admin page callbacks for the system module.

Code

function system_date_time_lookup($form, &$form_state) {
  $format = '';
  if (!empty($form_state['values']['date_format_pattern'])) {
    $format = t('Displayed as %date_format', array(
      '%date_format' => format_date(REQUEST_TIME, 'custom', $form_state['values']['date_format_pattern']),
    ));
  }

  // Return a command instead of a string, since the Ajax framework
  // automatically prepends an additional empty DIV element for a string, which
  // breaks the layout.
  $response = new AjaxResponse();
  $response
    ->addCommand(new ReplaceCommand('#edit-date-format-suffix', '<small id="edit-date-format-suffix">' . $format . '</small>'));
  return $response;
}