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

Select field options not updated when datasource changes

    XMLWordPrintable

Details

    • Yes
    • Basel 19
    • 2

    Description

      Steps to reproduce:

      1. define a select field (SF) in a form (F), with path (P) and repository pointing to a options set.
      2. run form F, select field SF options should be ok
      3. add a node N in options set path P.
      4. run form F, select field SF options does not contain node N.

      Expected behavour:
      Select field SF options should contain node N.

      Where is this bug/How to fix?
      In SelectFieldFactory.getSelectFieldOptionDefinition changed order of blocks in if/else, so when path is defined, then build remote options first.

      Patch:

      SelectFieldFactory.java
      diff --git a/magnolia-ui-form/src/main/java/info/magnolia/ui/form/field/factory/SelectFieldFactory.java b/magnolia-ui-form/src/main/java/info/magnolia/ui/form/field/factory/SelectFieldFactory.java
      index ecd1ed4..a123c0c 100644
      --- a/magnolia-ui-form/src/main/java/info/magnolia/ui/form/field/factory/SelectFieldFactory.java
      +++ b/magnolia-ui-form/src/main/java/info/magnolia/ui/form/field/factory/SelectFieldFactory.java
      @@ -159,7 +159,10 @@ public class SelectFieldFactory<D extends SelectFieldDefinition> extends Abstrac
           public List<SelectFieldOptionDefinition> getSelectFieldOptionDefinition() {
               List<SelectFieldOptionDefinition> res = new ArrayList<SelectFieldOptionDefinition>();
       
      -        if (definition.getOptions() != null && !definition.getOptions().isEmpty()) {
      +        if (StringUtils.isNotBlank(definition.getPath())) {
      +            // Build an option based on the referred node.
      +            buildRemoteOptions(res);
      +        } else if (definition.getOptions() != null && !definition.getOptions().isEmpty()) {
                   for (SelectFieldOptionDefinition option : definition.getOptions()) {
                       option.setValue(getValue(option));
                       option.setLabel(getMessage(getLabel(option)));
      @@ -171,9 +174,6 @@ public class SelectFieldFactory<D extends SelectFieldDefinition> extends Abstrac
                       }
                       res.add(option);
                   }
      -        } else if (StringUtils.isNotBlank(definition.getPath())) {
      -            // Build an option based on the referred node.
      -            buildRemoteOptions(res);
               }
       
               return res;
      

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                ngoc.nguyenthanh Ngoc Nguyenthanh
                jumper Marek Swiecznik
                Votes:
                1 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Bug DoR
                    Task DoD

                    Time Tracking

                      Estimated:
                      Original Estimate - 2d
                      2d
                      Remaining:
                      Time Spent - 1d 5.5h Remaining Estimate - 2.5h
                      2.5h
                      Logged:
                      Time Spent - 1d 5.5h Remaining Estimate - 2.5h
                      1d 5.5h