Validation error for height input field

Created on 3 June 2024, 7 months ago
Updated 6 June 2024, 7 months ago

Problem/Motivation

If the "Feet minimum" and "Feet maximum" settings are left blank when configuring a Webform Height input field, then filling out that form element will throw an error:

TypeError: Unsupported operand types: string - string in Drupal\Component\Utility\Number::validStep() (line 34 of core/lib/Drupal/Component/Utility/Number.php).
Drupal\Core\Render\Element\Number::validateNumber(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 281)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 238)

Steps to reproduce

1. Create a new webform
2. Add a new element to the form of type: "Height (feet/inches)".
3. Under "Height settings" clear the "Feet minimum" and "Feet maximum" values.
4. Save the element and the form.
5. View the form.
6. Enter any value for the height field setup above, and submit the form. You will see the error listed above.

(tested with Webform 6.2.2 and Drupal 10.2 and confirmed with a clean simplytest.me instance.

Proposed resolution

This could be fixed either by making the min/max fields in the element configuration required fields. Or changing the Webform Height submodule code to treat an empty string "" as a proper null so that the 'validStep doesn't fail due to the empty string parameter.

Notes

Given that editors need to remove the default values to trigger this error means it is fairly easy to avoid, though it would still be considered a bug.
I note that this scenario was previously showing as a warning in a D9 site, but appears to now be an error with D10 that breaks the form usage.

See attached screenshots for the above.

๐Ÿ› Bug report
Status

Active

Version

6.2

Component

Code

Created by

๐Ÿ‡ฟ๐Ÿ‡ฆSouth Africa Gomez_in_the_South

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024