[MAGNOLIA-6985] Area's auto creation: Creation of multi-value properties is not possible over Yaml Created: 22/Mar/17  Updated: 29/Mar/22  Resolved: 25/Jan/22

Status: Closed
Project: Magnolia
Component/s: templating
Affects Version/s: 5.5.2, 6.2.11
Fix Version/s: 6.2.16

Type: Bug Priority: Neutral
Reporter: Christian Ringele Assignee: Quach Hao Thien
Resolution: Fixed Votes: 0
Labels: maintenance, nucleus, to-verify
Remaining Estimate: Not Specified
Time Spent: 6d 7.5h
Original Estimate: Not Specified

Issue Links:
Relates
relates to MGNLFORM-362 FormFieldModel fails if invoked via a... Closed
causality
documentation
to be documented by MAGNOLIA-8291 DOC: Defining multi-value property fo... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Release notes required:
Yes
Documentation update required:
Yes
Date of First Response:
Sprint: Nucleus 1, Nucleus 2
Story Points: 3
Team: Nucleus

 Description   

Various fields create mutli-value properties (TwinColum etc).
So there is the need to be able to create mutli-value property also over the area's auto creation.

Here we run into a bug:
For creating a multi-value property one needs to pass a List into the property creation.
But when defining a List in yaml, it is provided as a HashMap (LinkedHashMap) and not as a List.

So the code expects that a sub-strucutre of node should be created -> HashMaps are used for defining sub-node strucutres.

Here form here info.magnolia.rendering.generator.CopyGenerator.createNode(Node, Map<String, Object>):

                    // a sub content
                    if (property.getValue() instanceof HashMap) {
                        Map<String, Object> map = new HashMap<String, Object>();
                        map.put(propertyName, value);
                        createNode(newNode, map);
                    }
                    else {
                        PropertyUtil.setProperty(newNode, propertyName, value);
                    }

The code will go into "if" and not "else" as a HashMap is returned.

Problem:
Defining in Yaml such Lists will be retruned as HAshMap:

food:
    - Sandwich
    - Pizza
    - Burrito
    - Chocolate cake

Also this type of List:

drinks: [coke, beer, water, milk]

Generated at Mon Feb 12 04:19:40 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.