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

DOC: Using currentItemProvider in complex fields

XMLWordPrintable

      Check whether it is still good practice to use currentItemProvider with composite and switchable fields. We are already warning against its use with multi fields (see https://documentation.magnolia-cms.com/display/DOCS62/Item+providers#Itemproviders-Foranydatasource).

      If you use currentItemProvider with complex fields, make sure that none of the inner field names clash with:

      • Other inner field names at the level where currentItemProvider is used
      • Other field names one level up where the complex field is defined

      In other words, when using currentItemProvider, every field at every level must have a unique name. Otherwise, nodes sharing the same name could be resolved by multiple fields that use currentItemProvider, which means their content would be overwritten.

      See the following example:

      form:
        properties:
          one_compositeField:
            $type: compositeField
            itemProvider:
              $type: currentItemProvider 
            properties:
              inner_simple:
                label: simple
                $type: textField # first text
              inner_simple2:
                label: simple
                $type: textField # second text
          second_compositeField:
            $type: compositeField
            itemProvider:
              $type: currentItemProvider
            properties:
              inner_simple:
                label: simple
                $type: textField # fourth text
              inner_simple3:
                label: simple
                $type: textField # third text
      ​
      # Problem:
      Einstein:
        inner_simple : fourth text # first text got overwritten
        inner_simple2 : second text
        inner_simple3: third text
      ​
      # Using jcrChildNodeProvider in both would fix the problem:
      Einstein:
        one_compositeField:
          inner_simple : first text
          inner_simple2 : second text
        second_compositeField:
          inner_simple : fourth text
          inner_simple2 : third text
      

        Acceptance criteria

              akhamis Ashraf Khamis
              akhamis Ashraf Khamis
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoR