1 filter.admin.inc filter_admin_format_form_submit($form, &$form_state)

Form submission handler for filter_admin_format_form().

See also

filter_admin_format_form_validate()

File

core/modules/filter/filter.admin.inc, line 670
Administrative page callbacks for the Filter module.

Code

function filter_admin_format_form_submit($form, &$form_state) {
  // Remove unnecessary values.
  form_state_values_clean($form_state);
  unset($form_state['values']['filter_settings']);
  unset($form_state['values']['actions']);

  // Add the submitted form values to the text format, and save it.
  $format = $form_state['format'];
  // Save allowed HTML tags from the hidden field in the event JS modified them.
  $allowed_html = $form_state['values']['allowed_html'];
  unset($form_state['values']['allowed_html']);

  foreach ($form_state['values'] as $key => $value) {
    $format->$key = $value;
  }
  // Get values from filter settings forms back from tempstore.
  if ($stored_format = filter_get_format_tempstore($format->format)) {
    foreach ($stored_format->filters as $name => $filter) {
      $format->filters[$name]['settings'] = $filter->settings;
    }
  }
  // Set allowed html, parked in a variable previously.
  $format->filters['filter_html']['settings']['allowed_html'] = $allowed_html;

  // If not saving an editor, do not save any settings.
  if (!$format->editor) {
    $format->editor_settings = array();
  }

  $status = filter_format_save($format);

  // Save user permissions.
  if ($permission = filter_permission_name($format)) {
    foreach ($format->roles as $rid => $enabled) {
      user_role_change_permissions($rid, array($permission => $enabled));
    }
  }

  switch ($status) {
    case SAVED_NEW:
      backdrop_set_message(t('Added text format %format.', array('%format' => $format->name)));
      break;

    case SAVED_UPDATED:
      backdrop_set_message(t('Updated text format %format.', array('%format' => $format->name)));
      break;
  }

  filter_clear_format_tempstore($format->format);
  $form_state['redirect'] = 'admin/config/content/formats';
}