Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2480

FormFragment can't be used in conjunction with HTML5 support

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.4
    • Fix Version/s: 5.4
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      Steps to reproduce:

      1. Use Chrome
      2. Set SymbolConstants.ENABLE_HTML5_SUPPORT to true
      3. Have a page with a form containing a FormFragment containing a field with the "required" validator
      4. Hide the FormFragment
      5. Attempt to submit the form
      6. Note that nothing happens and the following JS error appears in the Chrome dev tools console: "An invalid form control with name='whatever' is not focusable."

      This is due to the fact that when SymbolConstants.ENABLE_HTML5_SUPPORT is set to true, the "required" validator adds a "required" attribute to the form field, which in turn makes the browser want to validate it.

      At first I thought this could be fixed simply by a slight modification: whenever a form fragment handles the prepareForSubmit event and sets the fragment's hidden element's "disabled" attribute, it should also set the "disabled" attributes of all inputs, selects, textareas etc contained therein to the same value. This will disable native browser validation for these fields.

      However, I then realized that the prepareForSubmit event isn't even triggered by the browser in this case.

      This means that we shouldn't even rely on the prepareForSubmit event here, and instead set the disabled attribute (in the generated hidden field as well as the actual ones) whenever the "events.formfragment.changeVisibility" is triggered.

        Attachments

          Activity

            People

            • Assignee:
              hlship Howard M. Lewis Ship
              Reporter:
              annorax I D
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: