public function Full::validateOptionsForm in Views (for Drupal 7) 8.3
Provide the default form form for validating options
Overrides PagerPluginBase::validateOptionsForm
File
- lib/
Drupal/ views/ Plugin/ views/ pager/ Full.php, line 228 - Definition of Drupal\views\Plugin\views\pager\Full.
Class
- Full
- The plugin to handle full pager.
Namespace
Drupal\views\Plugin\views\pagerCode
public function validateOptionsForm(&$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,
)));
}
}
}