Uploaded image for project: 'eZ Platform Enterprise Edition'
  1. eZ Platform Enterprise Edition
  2. EZEE-3353

[Form builder] Using value "0" in Number field is not working

Details

    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

      1. check the required checkbox, and min = 0 , max = 10 , publish the content
      2. in front, put '0' in the number field
      3. 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

       

      Attachments

        Activity

          People

            vidar.langseid@ibexa.co Vidar Langseid
            tomasz.szopinski@ibexa.co Tomasz Szopiński
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: