Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Adding multifields based on numberfield in AEM 6.4


Level 3

Hello Everyone,

I am creating a component in which I need to add multifields based on the increment or decrement in the numberfield.


For example in the above dialog -  Suppose the author adds 3 in the numberfield, now he should be able to add only 3 sets of multifields in the dialog. That is he should be able to click on the "Add" button only 3 times and 3 sets of the field should be available. I am using Coral UI 3 for dialog creation.

Can anyone please provide some insights for the same? I have seen examples with checkbox and select but none with the numberfield.

Thanks and Regards,


Feike Visser smacdonald2008Arun PatidarVeena_07

0 Replies


Community Advisor


You need to write a listener same as to check min or max field but in your case min=max=number field.

no need to add data attribute(granite:data) node.

check this How to set min max item in Multifield AEM 6.3?


Level 3

Hi  Arun,

I tried the same solution but it did not work for the for the min max values. The listener does not work for me.

Although I'm using AEM 6.4, do you think that this might be a factor here?


Bernadine Soman


Community Advisor

It does work,

Please check sample script on dialog submit

I am using Coral3/Granite type field.

chrome-capture (1).gif

(function($, $document) {

    "use strict";

    $(document).on("click", ".cq-dialog-submit", function(e) {

        var inputSelector = $('#multi-number-id');

        var inputVal = inputSelector.find("input.coral3-Textfield").attr("aria-valuenow");


        var multifieldSelector = $('#multi-id');

        var multiFieldItem = multifieldSelector.find("coral-multifield-item").size();


                if (multiFieldItem !== inputVal) {

                function getDialog() {

            var dialog = new Coral.Dialog();

   = 'dialogId';

            dialog.header.innerHTML = '<coral-alert-header>Dialog cannot be submitted</coral-alert-header>';

            dialog.content.innerHTML = '<coral-alert-content>Number of multifield Items are not equal to Number</coral-alert-content>';

            dialog.footer.innerHTML = '<button is="coral-button" variant="primary" coral-close><coral-button-label>Ok</coral-button-label></button>';

            dialog.variant = "error";

            return dialog;


                    var dialog = getDialog();



                    return false;



$(document).on("change", "#multi-number-id", function(e) {

        var inputSelector = $('#multi-number-id');

        var inputVal;


        inputVal = inputSelector.find("input.coral3-Textfield").attr("aria-valuenow");


        var multifieldSelector = $('#multi-id');

        var multiFieldItem = multifieldSelector.find("coral-multifield-item").size();

        if (multiFieldItem >= inputVal) {





    }, 100);


})($, $(document));


Community Advisor

"#multi-number-id" and "#multi-id"  are the selectors to input field and multifield
you need to add granite:id if using Coral3 type otherwise id property to input filed and multifield
multifield node


Level 3

Hi Dushan,

Thank you for the input, however I'm trying the restrict the addition of fields inside a multifield, so if you have any insights on that it would be helpful.


Bernadine Soman

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now