You are here

function facetapi_facet_display_form_validate in Facet API 7.2

Same name and namespace in other branches
  1. 6.3 facetapi.admin.inc \facetapi_facet_display_form_validate()
  2. 7 facetapi.admin.inc \facetapi_facet_display_form_validate()

Form validation handler for facetapi_facet_display_form().

1 string reference to 'facetapi_facet_display_form_validate'
facetapi_facet_display_form in ./facetapi.admin.inc
Form constructor for the facet display settings form.

File

./facetapi.admin.inc, line 764
Admin page callbacks for the Facet API module.

Code

function facetapi_facet_display_form_validate($form, &$form_state) {
  ctools_include('plugins');

  // Gets the selected query type and widget.
  $query_type = $form_state['values']['global']['query_type'];
  $widget_name = $form_state['values']['widget'];

  // Loads the widget plugin, makes sure it supports the selected type.
  if ($widget = ctools_get_plugins('facetapi', 'widgets', $widget_name)) {
    $widget_types = drupal_map_assoc($widget['handler']['query types']);
    if (!isset($widget_types[$query_type])) {
      $error = t('The widget does not support the %type query type', array(
        '%type' => $query_type,
      ));
      form_set_error('widget', $error);
    }
  }
  else {
    $error = t('Widget %name not valid.', array(
      '%name' => $widget_name,
    ));
    form_set_error('widget', $error);
  }
}