enonic / xp

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

java.lang.IllegalArgumentException: FormItem [] in [INPUTNAME] is not of type Input: com.enonic.xp.form.FieldSet #5778

Closed ComLock closed 6 years ago

ComLock commented 6 years ago

I have a contentType with this:

<field-set name="securityClassification">
            <label>Security classification</label>
            <items>
                <inline mixin="security-classification" />
            </items>
        </field-set>

The mixin

<mixin>
    <displayName>Security classification</displayName>
    <items>
        <input name="securityClassification" type="ComboBox">
            <label>Security level</label>
            <occurrences minimum="0" maximum="1"/>
            <config>
                <option value="public">Public</option>
                <option value="internal">Internal</option>
                <option value="restricted">Restricted</option>
                <option value="confidential">Confidential</option>
                <option value="strictly-confidential">Strictly confidential</option>
            </config>
            <default>public</default>
        </input>
    </items>
</mixin>

When securityClassification is set to the default public

I get the error: java.lang.IllegalArgumentException: FormItem [] in [securityClassification] is not of type Input: com.enonic.xp.form.FieldSet

Bellfalasch commented 6 years ago

Not a bug. Mixins are not allowed that deep. It needs to be included as imediate child to the config-node level.

ComLock commented 6 years ago

That cannot be true. I believe I have included mixins on many levels before. And mixins within mixins and so on.

ComLock commented 6 years ago

I forgot to mention this works fine in Content Studio.

The error appears when I try to use content.modify.

Bellfalasch commented 6 years ago

Then that was a mistake / pure luck. It has never been meant to work and should fail.

ComLock commented 6 years ago

The doc doesn't say anything about it having to be root level.

http://xp.readthedocs.io/en/stable/developer/schema/mixins.html

alansemenov commented 6 years ago

@aro should we fix the docs to say that mixins must be on top level or should we fix content.modify to work in this case?

aro commented 6 years ago

I think the problem is that you use the same name for the field-set and the input at the top level of the mixin: "securityClassification".

A field-set is just a UI wrapper, it does not add a new level for the data inside (as opposed to item-set). So field-set should probably not have had a "name", but it does. And there is a conflict when an item inside the mixin has the same name of the field-set.

So basically, don't do that :) I think it's not a simple solution to fix without breaking other cases.

@ComLock can you try just renaming the field-set, since that name is not used for anything anyway?

<field-set name="securityClassification22"> <---
      <label>Security classification</label>
      <items>
          <inline mixin="security-classification" />
      </items>
</field-set>

Mixins are fine, can be nested, there is no problem with that.

ComLock commented 6 years ago

@aro I will try changing the field-set name. This is not easy to spot though, as the name of the input is in a different file, namely the mixin file.