public function DateFormatFormBase::submitForm

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

array $form_state: An associative array containing the current state of the form.

Overrides FormInterface::submitForm

File

drupal/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php, line 52
Contains \Drupal\system\Form\DateFormatFormBase.

Class

DateFormatFormBase
Provides a base form for date formats.

Namespace

Drupal\system\Form

Code

public function submitForm(array &$form, array &$form_state) {
  $format = array();
  $format['name'] = String::checkPlain($form_state['values']['date_format_name']);
  $format['pattern'][$this->patternType] = 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';
}