[MGNLUI-6320] DOC: Using currentItemProvider in complex fields Created: 15/Oct/20  Updated: 29/Oct/20  Resolved: 29/Oct/20

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 6.2
Fix Version/s: None

Type: Task Priority: Neutral
Reporter: Ashraf Khamis Assignee: Ashraf Khamis
Resolution: Done Votes: 0
Labels: fields, new-UI-framework, new-form
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MGNLUI-6222 DOC: currentItemProvider should not b... Closed
relates to MGNLUI-6316 DOC: Default to jcrChildNodeProvider ... Closed
relates to MGNLUI-6332 DOC: Better explanation of itemProvid... Closed
Template:
Acceptance criteria:
Empty
Task DoR:
Empty
Epic Link: DOC: Restructure common field properties
Sprint: UI FW 14
Story Points: 2

 Description   

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


 Comments   
Comment by Ashraf Khamis [ 29/Oct/20 ]

Updated https://documentation.magnolia-cms.com/display/DOCS62/Item+providers#Itemproviders-Foranydatasource with:

  • A note about how to properly use currentItemProvider with composite or switchable fields
  • A name conflict that could happen when using currentItemProvider incorrectly

Reviewed by Šimon.

Generated at Mon Feb 12 09:35:18 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.