Uploaded image for project: 'Click'
  1. Click
  2. CLK-722

Improve Fields to only set their value and validate if there is a matching request parameter

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.0-M1
    • Component/s: core
    • Labels:
      None

      Description

      Currently Fields set their values and validate even if there is no incoming request parameter available. This is problematic for dynamically added fields where a default value is set (this value gets overwritten when the Field is processed) and the field is validated and an error message is displayed without the user having seen this field before.

      I suggest Field onProcess changed from this:

      public boolean onProcess() {
      bindRequestValue();
      if (getValidate())

      { validate(); }

      dispatchActionEvent();
      ...
      }

      to this:

      public boolean onProcess() {
      if (getContext().hasParameter(getName()) {
      bindRequestValue();
      if (getValidate())

      { validate(); }

      dispatchActionEvent();
      ...
      }
      }

      I can see at least three reasons why the Field value won't be present:

      1. The field was dynamically added to the form in the POST request
      2. The field was disabled through JS (HTML does not post a disabled field value)
      3. The field is an unchecked Checkbox or Radio (HTML does not post unchecked checkbox or radio values)

      This feature is a good supplement to the dynamic Form support added in 2.2.0.

        Activity

        Hide
        sabob Bob Schellink added a comment -

        done

        Show
        sabob Bob Schellink added a comment - done

          People

          • Assignee:
            sabob Bob Schellink
            Reporter:
            sabob Bob Schellink
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development