Details
-
Bug
-
Resolution: Unresolved
-
Medium
-
2.5.14, 3.1.4, 3.2.1, 4.5.3
Description
When providing a value of "0" in a number field, it is considered as value null.
- It is stored as null in the database.
- If field is "required", it will give validation error when zero (0) is provided.
- Even if value 0 is stored as submitted in DB, it will appear as empty in submission list
Steps to reproduce:
1. create Form CT with with Number form field
2. in 'Number' form field enable validation, set min_value=0, max_value=10
3. go to Page
4. create a new Landing Page
5. add Form CT from 1.
6. publish LP
7. in preview add '0' to form
8. click Enter
Actual result:
'This value is required' message occurs.
Expected result:
'0' is an acceptable value
From community:
I think there is an issue with NumberFieldType in form builder (ezp 2.5) : # create a form with a Number field
- check the required checkbox, and min = 0 , max = 10 , publish the content
- in front, put '0' in the number field
- you get an Required validation error , because 0 is considered as empty !
Can anyone reproduce this issue ?It seems to come from : vendor/ezsystems/ezplatform-form-builder/src/lib/Form/Type/Field/NumberFieldType.php:39 : if (empty($value)) { return null; } where $value is 0.0