1 views_plugin_pager_full.inc views_plugin_pager_full::options_validate(&$form, &$form_state)

Provide the default form form for validating options

Overrides views_plugin_pager::options_validate

File

core/modules/views/plugins/views_plugin_pager_full.inc, line 216
Definition of views_plugin_pager_full.

Class

views_plugin_pager_full
The plugin to handle full pager.

Code

function options_validate(&$form, &$form_state) {
  // Only accept integer values.
  $error = FALSE;
  $exposed_options = $form_state['values']['pager_options']['expose']['items_per_page_options'];
  if (strpos($exposed_options, '.') !== FALSE) {
    $error = TRUE;
  }
  $options = explode(',', $exposed_options);
  if (!$error && is_array($options)) {
    foreach ($options as $option) {
      if (!is_numeric($option) || intval($option) == 0) {
        $error = TRUE;
      }
    }
  }
  else {
    $error = TRUE;
  }
  if ($error) {
    form_set_error('pager_options][expose][items_per_page_options', t('Please insert a list of integer numeric values separated by commas: e.g: 10, 20, 50, 100'));
  }

  // Take sure that the items_per_page is part of the expose settings.
  if (!empty($form_state['values']['pager_options']['expose']['items_per_page']) && !empty($form_state['values']['pager_options']['items_per_page'])) {
    $items_per_page = $form_state['values']['pager_options']['items_per_page'];
    if (array_search($items_per_page, $options) === FALSE) {
      form_set_error('pager_options][expose][items_per_page_options', t('Please insert the items per page (@items_per_page) from above.', 
      array('@items_per_page' => $items_per_page))
      );
    }
  }
}