diff --git a/includes/admin.inc b/includes/admin.inc index 0cace87ecfa6ec094bb2c9c4f88dc0064216da5c..fadab0a90fa21cc90560ef71de1b2820965da52c 100644 --- a/includes/admin.inc +++ b/includes/admin.inc @@ -409,22 +409,6 @@ function views_ui_add_form($form, &$form_state) { return $form; } -/** - * Helper form element validator: integer. - * - * The problem with this is that the function is private so it's not guaranteed - * that it might not be renamed/changed. In the future field.module or something else - * should provide a public validate function. - * - * @see _element_validate_integer_positive() - */ -function views_element_validate_integer($element, &$form_state) { - $value = $element['#value']; - if ($value !== '' && (!is_numeric($value) || intval($value) != $value)) { - form_error($element, t('%name must be a positive integer.', array('%name' => $element['#title']))); - } -} - /** * Gets the current value of a #select element, from within a form constructor function. * diff --git a/lib/Drupal/views/Plugin/views/style/Grid.php b/lib/Drupal/views/Plugin/views/style/Grid.php index e68049744b4b2e5d45a0758564c411c806f30a48..d3b873e9ebddbdc8359562b7bdaad5e12599ce13 100644 --- a/lib/Drupal/views/Plugin/views/style/Grid.php +++ b/lib/Drupal/views/Plugin/views/style/Grid.php @@ -51,11 +51,11 @@ function option_definition() { function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['columns'] = array( - '#type' => 'textfield', + '#type' => 'number', '#title' => t('Number of columns'), '#default_value' => $this->options['columns'], '#required' => TRUE, - '#element_validate' => array('views_element_validate_integer'), + '#min' => 0, ); $form['alignment'] = array( '#type' => 'radios', diff --git a/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php index af3091f479d9dd39d86c60659447eb27264d3955..bc08f89005f71c0e5ad4df1074b4d2b4352f3f01 100644 --- a/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php +++ b/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php @@ -116,10 +116,9 @@ function build_form($form, &$form_state) { $this->build_form_style($form, $form_state, 'page'); $form['displays']['page']['options']['items_per_page'] = array( '#title' => t('Items to display'), - '#type' => 'textfield', - '#default_value' => '10', - '#size' => 5, - '#element_validate' => array('views_element_validate_integer'), + '#type' => 'number', + '#default_value' => 10, + '#min' => 0, ); $form['displays']['page']['options']['pager'] = array( '#title' => t('Use a pager'), @@ -253,10 +252,9 @@ function build_form($form, &$form_state) { $this->build_form_style($form, $form_state, 'block'); $form['displays']['block']['options']['items_per_page'] = array( '#title' => t('Items per page'), - '#type' => 'textfield', - '#default_value' => '5', - '#size' => 5, - '#element_validate' => array('views_element_validate_integer'), + '#type' => 'number', + '#default_value' => 5, + '#min' => 0, ); $form['displays']['block']['options']['pager'] = array( '#title' => t('Use a pager'),