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

Custom Block with select attribute and choice with value "0" will trigger NotBlank validator

    XMLWordPrintable

Details

    Description

      When you add a Custom Block with select attribute and NotBlank validator, that contains the choice with value 0 and this choice selected, validation will fail.

      Steps to reproduce
      1. Clean installation of eZ Platform 2.5 / 3.0
      2. Create a new custom block testblock in ezplatform.yml:

      ezplatform_page_fieldtype:
          blocks:
              testbblock:
                  name: 'Test Block'
                  thumbnail: '/bundles/ezplatformadminui/img/ez-icons.svg#contentlist'
                  views:
                      testblock:
                          # template: 'blocks/testblock.html.twig' on 3.0
                          template: 'AppBundle:blocks:testblock.html.twig'
                          name: 'Default block template'
                  attributes:
                      select:
                          type: select
                          options:
                              multiple: false
                              choices:
                                  'Option 1': 0
                                  'Option 2': 1
                          validators:
                              not_blank:
                                  message: Please provide a valid option
      

      3. Create a template file for the block
      src/AppBundle/Resources/views/blocks/testblock.html.twig (3.0: templates/blocks/testblock.html.twig)

      Test Block
      

      4. Create a new Landing Page, put Test Block inside, and choose "Option 1".

      Result
      Block validation will fail.

      Expected Result
      Block will validate successfully.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mateusz.bieniek@ibexa.co Mateusz Bieniek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: