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

Ajax handler: Opens the dialog to configure a text format filter.

File

core/modules/filter/filter.admin.inc, line 489
Admin page callbacks for the Filter module.

Code

function filter_admin_format_filter_settings_form_ajax($form, &$form_state) {
  // If there are form errors, show them and scroll to the top of the page.
  if (form_get_errors()) {
    $commands[] = ajax_command_html('#filter-messages', theme('status_messages'));
    $commands[] = ajax_command_redirect('#filter-messages');
  }
  // If no form errors, open the configure dialog.
  else {
    $trigger = $form_state['triggering_element'];
    $name = $trigger['#name'];
    // Load previously added settings from tempstore, if any.
    if ($stored_format = filter_get_format_tempstore($form_state['format']->format)) {
      $format = $stored_format;
    }
    else {
      $format = $form_state['format'];
    }

    $configure_form = backdrop_get_form('filter_admin_format_filter_settings_form', $format, $name);
    $title = t('Configure filter');
    $options = array(
      'dialogClass' => 'filter-dialog',
      'width' => '90%',
    );

    $html = '';
    $html .= theme('status_messages');
    $html .= '<div data-filter-name="' . $name . '" class="filter-dialog-settings">';
    $html .= backdrop_render($configure_form);
    $html .= '</div>';

    $commands = array();
    $commands[] = ajax_command_html('#filter-messages', '');
    $commands[] = ajax_command_open_modal_dialog($title, $html, $options);
  }

  return array('#type' => 'ajax', '#commands' => $commands);
}