Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-3748

Impossible to have a select option field with empty value.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Neutral
    • None
    • 5.4.2
    • dialogs
    • None

    Description

      Sometimes it is more or less logical to have a option in a dropbown box with an empty value. E.g. we used it to indicate 'leave this value empty and inherit it from parent nodes'. But is does not work, and unexpectedly the name of the option is used then.

      See
      info.magnolia.ui.form.field.factory.SelectFieldFactory

      
          /**
           * Backward compatibility.
           * If value is null, <br>
           * - get the Name as value.<br>
           * - If Name is empty, set Label as value.
           */
        private String getValue(SelectFieldOptionDefinition option) {
              if (StringUtils.isBlank(option.getValue())) {
                  if (StringUtils.isNotBlank(option.getName())) {
                      return option.getName();
                  } else {
                      return getMessage(getLabel(option));
                  }
              } else {
                  return option.getValue();
              }
          }
      

      The code is also private, so it is hard to change this default somewhat counter intuitive behaviour.

      I'm not sure how this facilitates some backwards compatibility. It may do, I'm not sure. I'd sure like an option to switch on/off this.

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              mihxil Michiel Meeuwissen
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD