enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
201 stars 34 forks source link

Same field-set and child item-set name-attribute in a contenttype throws exception in the content.modify API #6262

Closed RF0 closed 6 years ago

RF0 commented 6 years ago

Enonic XP 6.14.2

In a contenttype, when a field-set name-attribute is the same as the name-attribute of a child item-set, it works in Content Studio, but produces exception when the content is modified with the content.modify API call.

Exception Message: FormItem [] in [attributes] is not of type Input: com.enonic.xp.form.FieldSet

Example schema (renaming field-set name to f.x. inputAttributes will avoid exception) Real life example

<field-set name="attributes">
    <label>Input attributes</label>
    <items>
        <item-set name="attributes">
            <label>attributes</label>
            <occurrences minimum="0" maximum="0"/>
            <items>
                <inline mixin="freeform-name-value"/>
            </items>
        </item-set>
    </items>
</field-set>
sigdestad commented 6 years ago

We must "disable" names from field-sets in 6.15!!

alansemenov commented 6 years ago

"disable" as in "stop using" them? we cannot remove the attribute from the schema as of yet since it will break down things, but we can stop using it in the code I guess.

sigdestad commented 6 years ago

The task is basically to make the name attribute optional in fieldsets i 6.15, for 7.0 we can drop it completely.

aro commented 6 years ago

We cannot make name optional in fieldset now without breaking things. The FieldSet class in Java extends from FormItem which has a required name field. We can do that change in 7.0

I made a pull request which fixes the issue in the JSON to PropertyTree resolving, based on a form schema. So that it traverses the form ignoring the name of the fieldsets. This will solve this issues and other related that have been reported in Discuss.