#2336443: NumericItemBase uses '#type' => 'textfield' for numeric 'min' and 'max' form fields
Commit message: Issue #2336443 by drunken monkey: NumericItemBase uses '#type' => 'textfield' for numeric 'min' and 'max' form fields.

Problem/Motivation

Initially raised by @drunken monkey at #2326891-35: Convert system_element_info() to Element classes

\Drupal\Core\Field\Plugin\Field\FieldType\NumericItemBase uses element type 'textfield' and 'form_validate_number' as #element_validate callback for the 'min' and 'max' form fields. Since these are actually numbers, the 'number' element type should be used.

Proposed resolution

Use '#type' => 'number' for the 'min' and 'max' form fields.

Remaining tasks

Patch
Reviews
Commit

User interface changes

None

API changes

None

CommentFileSizeAuthor
numeric_item_base.patch1.22 KBalmaudoh

Comments

almaudoh’s picture

Issue summary: View changes
Status: Active » Needs review
swentel’s picture

Status: Needs review » Needs work
Related issues: +#2332685: form_validate_number is still refered too
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php
@@ -35,18 +35,16 @@ public function instanceSettingsForm(array $form, FormStateInterface $form_state
-      '#element_validate' => array('form_validate_number'),

We can't remove the validate - however, this function does not exist anymore, but needs to be replace, see #2332685: form_validate_number is still refered too

swentel’s picture

Status: Needs work » Needs review

Actually, I might be wrong, let me investigate first.

clemens.tolboom’s picture

Issue summary: View changes
almaudoh’s picture

@swentel, during refactoring of #2326891: Convert system_element_info() to Element classes form_validate_number() was converted to Number::validateNumber() and is the 'number' element's default '#element_validate' callback, so doesn't need to be explicitly mentioned.

swentel’s picture

Status: Needs review » Reviewed & tested by the community

Indeed it is.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 22bb037 and pushed to 8.0.x. Thanks!

  • alexpott committed 22bb037 on 8.0.x
    Issue #2336443 by almaudoh: NumericItemBase uses '#type' => 'textfield'...
almaudoh’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.