Error when modifying the object

Enonic version: 6.14.2
OS: MacOS/Linux

Hi there,
I faced the issue with saving modified data. I’m confused because of the error message FormItem [] in [skills] is not of type Input: com.enonic.xp.form.FieldSet on the other hand if I do make changes in content studio, there are no problems. Could you point me to where I could be wrong.

upd2: No, the issue is still there. :frowning:

update profile snippet
var profile = libs.content.get({key: req.params.id});
var updateData = getDataToModify(req.params);

var fnEditor = function (u) {
    var p = req.params;
    u.data = profile.data;
    for ( var key in updateData ) {
        u.data[key] = updateData[key];
    }
    u.modifiedTime = new Date().toISOString();
    return u;
};

var response = blackProf.editProfile(profile, fnEditor);

function modifyProfile(profile, fnEditor) {
var result = runAsAdmin( function() {
    return libs.content.modify({
        key: profile._id,
        editor: fnEditor,
        branch: 'draft'
        });
    });
return result;
}
xml skill snippet Select skills Skills info false
    <options minimum="0" maximum="5">
        <option name="langSkills">
            <label i18n="skills.lang-skills.label">Languages</label>
            <items>
                <item-set name="langSkillSelector">
                    <label>Programming Languages</label>
                    <items>
                        <input name="skillNode" type="ContentSelector">
                            <label i18n="skills.select-skill.label">Select Language</label>
                            <occurrences minimum="1" maximum="1" />
                            <config>
                                <relationshipType>system:reference</relationshipType>
                                <allowContentType>skill</allowContentType>
                                <allowPath>${site}/skills/languages/</allowPath>
                            </config>
                        </input>
                        <inline mixin="skill-attributes"/>
                    </items>
                    <occurrences minimum="0" maximum="0"/>
                </item-set>
            </items>
        </option>





part of error listing
2018-05-29 12:44:56,085 ERROR c.e.x.p.i.e.ExceptionRendererImpl - FormItem [] in [skills] is not of type 
Input: com.enonic.xp.form.FieldSet
    com.enonic.xp.web.WebException: FormItem [] in [skills] is not of type Input: com.enonic.xp.form.FieldSet
at com.enonic.xp.web.impl.exception.ExceptionMapperImpl.map(ExceptionMapperImpl.java:32)
at com.enonic.xp.portal.handler.BasePortalHandler.handleError(BasePortalHandler.java:62)
at com.enonic.xp.portal.handler.BasePortalHandler.doHandle(BasePortalHandler.java:54)
at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:66)
at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
at com.enonic.xp.web.impl.trace.TraceWebFilter.doHandle(TraceWebFilter.java:37)
at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:66)
at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
at com.enonic.xp.web.impl.handler.WebDispatcherImpl.dispatch(WebDispatcherImpl.java:50)
at com.enonic.xp.web.impl.handler.WebDispatcherServlet.doHandle(WebDispatcherServlet.java:135)
at com.enonic.xp.web.impl.handler.WebDispatcherServlet.service(WebDispatcherServlet.java:63)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at com.enonic.xp.web.impl.dispatch.mapping.ServletDefinitionImpl.service(ServletDefinitionImpl.java:39)
at com.enonic.xp.web.impl.dispatch.pipeline.ServletPipelineImpl.service(ServletPipelineImpl.java:30)
at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:45)
at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:36)
at com.enonic.xp.portal.impl.auth.AuthFilter.doHandle(AuthFilter.java:45)
at com.enonic.xp.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:31)
at com.enonic.xp.web.filter.BaseWebFilter.doFilter(BaseWebFilter.java:33)
...

I admitted if the structure of xml was wrong I wouldn’t be able to create new objects in content studio.
On the other hand, If the object (profile) has no skills selected, it can be modified well using the functions listed above. But once I add skills in content studio and then do content.modify – it gives me this error.

Could you help me please?

Thanks in advance.

I decided to add the fragment of json view to clarify the picture.

"skills": {
        "_selected": [
            "langSkills",
            "toolSkills"
        ],
        "langSkills": {
            "langSkillSelector": {
                "skillNode": "ecc3306b-b142-4ab3-b820-cb823a364cd4",
                "level": "4",
                "years": "3"
            }
        },
        "toolSkills": {
            "toolSkillSelector": {
                "skillNode": "d6f76b53-d4c0-4750-b461-3a94448b6e44",
                "level": "3",
                "years": "3"
            }
        }
    }

I believe that this somehow is similar to the topic Unable to edit object with attachment with content.modify it’s just I’m not sure I do correct things.

Any hints?

Can you post the content type xml?
I will try to reproduce it.

Hi Nat

We had a similar issue recently (https://github.com/enonic/xp/issues/6262). The reason as it turned out was that “field-set” and its child “item-set” had the same name. Solution is to remove “name” attribute for fieldset.

Hello @aro and @ase,
thank you for your replies. This is what I have in my xmls

<content-type>
<display-name i18n="profile.display-name">Profile</display-name>
<super-type>base:structured</super-type>
<form>
    <field-set name="skills">
        <label i18n="profile.skills.label">Skills</label>
        <items>
            <inline mixin="skills-set"/>
        </items>
    </field-set>
...
</form>

And skills-set.xml is

<mixin>
<display-name>Select skills</display-name>
<items>
    <option-set name="skillsSet">
        <label>Skills info</label>
        <expanded>false</expanded>

        <options minimum="0" maximum="5">
            <option name="langSkills">
                <label i18n="skills.lang-skills.label">Languages</label>
                <items>
                    <item-set name="langSkillSelector">
                        <label>Programming Languages</label>
                        <items>
                            <input name="skillNode" type="ContentSelector">
                                <label i18n="skills.select-skill.label">Select Language</label>
                                <occurrences minimum="1" maximum="1" />
                                <config>
                                    <relationshipType>system:reference</relationshipType>
                                    <allowContentType>skill</allowContentType>
                                    <allowPath>${site}/skills/languages/</allowPath>
                                </config>
                            </input>
                            <inline mixin="skill-attributes"/>
                        </items>
                        <occurrences minimum="0" maximum="0"/>
                    </item-set>
                </items>
            </option>

            <option name="osSkills">
                <label i18n="skills.lang-skills.label">Platforms</label>
                <items>
                    <item-set name="osSkillSelector">
                        <label>Operation Systems</label>
                        <items>
                            <input name="skillNode" type="ContentSelector">
                                <label i18n="skills.select-skill.label">Select OS</label>
                                <occurrences minimum="1" maximum="1" />
                                <config>
                                    <relationshipType>system:reference</relationshipType>
                                    <allowContentType>skill</allowContentType>
                                    <allowPath>${site}/skills/os/</allowPath>
                                </config>
                            </input>
                            <inline mixin="skill-attributes"/>
                        </items>
                        <occurrences minimum="0" maximum="0"/>
                    </item-set>
                </items>
            </option>

            <option name="toolSkills">
                <label i18n="skills.lang-skills.label">Tools</label>
                <items>
                    <item-set name="toolSkillSelector">
                        <label>Tools</label>
                        <items>
                            <input name="skillNode" type="ContentSelector">
                                <label i18n="skills.select-skill.label">Select Tool</label>
                                <occurrences minimum="1" maximum="1" />
                                <config>
                                    <relationshipType>system:reference</relationshipType>
                                    <allowContentType>skill</allowContentType>
                                    <allowPath>${site}/skills/tools/</allowPath>
                                </config>
                            </input>
                            <inline mixin="skill-attributes"/>
                        </items>
                        <occurrences minimum="0" maximum="0"/>
                    </item-set>
                </items>
            </option>

            <option name="frameworkSkills">
                <label i18n="skills.lang-skills.label">Frameworks</label>
                <items>
                    <item-set name="frameworkSkillSelector">
                        <label>Frameworks</label>
                        <items>
                            <input name="skillNode" type="ContentSelector">
                                <label i18n="skills.select-skill.label">Select Framework</label>
                                <occurrences minimum="1" maximum="1" />
                                <config>
                                    <relationshipType>system:reference</relationshipType>
                                    <allowContentType>skill</allowContentType>
                                    <allowPath>${site}/skills/frameworks/</allowPath>
                                </config>
                            </input>
                            <inline mixin="skill-attributes"/>
                        </items>
                        <occurrences minimum="0" maximum="0"/>
                    </item-set>
                </items>
            </option>
        </options>
    </option-set>
</items>

Hi @ase again,

first I had the same issue as you did with the same names in field-set and option-set but then I changed it and it didn’t work out either. That’s why I stuck as a rusty nail in the door. Re-build and re-deployed. Same error.

You still have it. Remove name attribute from <field-set name="skills">

I might don’t see but now field-set has name=‘skills’ and option-set has name=‘skillsSet’. What for to remove name=‘skills’ from field-set?

The name “skills” is what binds the data to the model, an in this case “skills” refers to a fieldset, not the opitonset. Try changing your input data object to be named “skillSet” instead of “skills”

1 Like

Hi @tsi,
yes, thank you. I just figure out it too :D, changing option-set to skillsSet modified my json view. Ah, thank you for your time!

Thank you all guys!