function system_date_formats_form_submit

Process date format string submission.

1 string reference to 'system_date_formats_form_submit'
system_configure_date_formats_form in drupal/core/modules/system/system.admin.inc
Allow users to add additional date formats.

File

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

Code

function system_date_formats_form_submit($form, &$form_state) {
  $date = new DrupalDateTime();
  $pattern_type = $date
    ->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP;
  $format = array();
  $format['name'] = check_plain($form_state['values']['date_format_name']);
  $format['pattern'][$pattern_type] = trim($form_state['values']['date_format_pattern']);
  $format['locales'] = !empty($form_state['values']['date_langcode']) ? $form_state['values']['date_langcode'] : array();

  // Formats created in the UI are not locked.
  $format['locked'] = 0;
  system_date_format_save($form_state['values']['date_format_id'], $format);
  if (!empty($form_state['values']['date_format_id'])) {
    drupal_set_message(t('Custom date format updated.'));
  }
  else {
    drupal_set_message(t('Custom date format added.'));
  }
  $form_state['redirect'] = 'admin/config/regional/date-time/formats';
}