Nested Multifield within multifield in content fragment model not working in aem . | Community
Skip to main content
New Participant
March 5, 2024
Solved

Nested Multifield within multifield in content fragment model not working in aem .

  • March 5, 2024
  • 2 replies
  • 488 views

Want a multifield inside multifield in content fragment model , have tried with custom js and dialog but still not working any idea please share it .

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Raja_Reddy

Hi @padmanabhsaoji 

  1. Define the outer multifield: In your Content Fragment Model, define the outer multifield as you normally would. 

    {
        "title": "My Multifield",
        "name": "./myMultifield",
        "fieldLabel": "My Multifield",
        "xtype": "multifield",
        "addLabel": "Add Item",
        "fieldConfig": {
            "xtype": "textfield",
            "name": "./myTextField",
            "fieldLabel": "My Text Field"
        }
    }
    
  2. Define the inner multifield: In the fieldConfig object of the outer multifield, define the inner multifield as a custom xtype. For example:

    {
        "title": "My Multifield",
        "name": "./myMultifield",
        "fieldLabel": "My Multifield",
        "xtype": "multifield",
        "addLabel": "Add Item",
        "fieldConfig": {
            "xtype": "custommultifield",
            "name": "./myCustomMultifield",
            "fieldLabel": "My Custom Multifield"
        }
    }
    
  3. Define the custom xtype: In your Content Fragment Model's client library, define the custom xtype for the inner multifield. For example:

    CQ.Ext.define("myproject.CustomMultifield", {
        extend: "CQ.form.MultiField",
        constructor: function(config) {
            config = config || {};
            var defaults = {
                "fieldConfig": {
                    "xtype": "textfield",
                    "name": "./myInnerTextField",
                    "fieldLabel": "My Inner Text Field"
                }
            };
            config = CQ.Util.applyDefaults(config, defaults);
            myproject.CustomMultifield.superclass.constructor.call(this, config);
        }
    });
    
  4. Include the client library: In your Content Fragment Model's dialog, include the client library that defines the custom xtype. For example:

    <cq:dialog
        ...
        <cq:includeClientLib categories="myproject.custommultifield"/>
        ...
    </cq:dialog>

    https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/nested-multifield-in-content-fragment-aem-6-5/m-p/421857 
    https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/multifield-in-content-fragment-model/td-p/246514 

2 replies

kautuk_sahni
Employee
March 7, 2024

@padmanabhsaoji Did you find the suggestion helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni
Raja_Reddy
Raja_ReddyAccepted solution
New Participant
March 5, 2024

Hi @padmanabhsaoji 

  1. Define the outer multifield: In your Content Fragment Model, define the outer multifield as you normally would. 

    {
        "title": "My Multifield",
        "name": "./myMultifield",
        "fieldLabel": "My Multifield",
        "xtype": "multifield",
        "addLabel": "Add Item",
        "fieldConfig": {
            "xtype": "textfield",
            "name": "./myTextField",
            "fieldLabel": "My Text Field"
        }
    }
    
  2. Define the inner multifield: In the fieldConfig object of the outer multifield, define the inner multifield as a custom xtype. For example:

    {
        "title": "My Multifield",
        "name": "./myMultifield",
        "fieldLabel": "My Multifield",
        "xtype": "multifield",
        "addLabel": "Add Item",
        "fieldConfig": {
            "xtype": "custommultifield",
            "name": "./myCustomMultifield",
            "fieldLabel": "My Custom Multifield"
        }
    }
    
  3. Define the custom xtype: In your Content Fragment Model's client library, define the custom xtype for the inner multifield. For example:

    CQ.Ext.define("myproject.CustomMultifield", {
        extend: "CQ.form.MultiField",
        constructor: function(config) {
            config = config || {};
            var defaults = {
                "fieldConfig": {
                    "xtype": "textfield",
                    "name": "./myInnerTextField",
                    "fieldLabel": "My Inner Text Field"
                }
            };
            config = CQ.Util.applyDefaults(config, defaults);
            myproject.CustomMultifield.superclass.constructor.call(this, config);
        }
    });
    
  4. Include the client library: In your Content Fragment Model's dialog, include the client library that defines the custom xtype. For example:

    <cq:dialog
        ...
        <cq:includeClientLib categories="myproject.custommultifield"/>
        ...
    </cq:dialog>

    https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/nested-multifield-in-content-fragment-aem-6-5/m-p/421857 
    https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/multifield-in-content-fragment-model/td-p/246514