Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Mandatory Fields in Hidden Subforms

Avatar

Former Community Member

Hello,

I have 3 subforms which are hidden and only appear when a check box is clicked.  Within these hidden forms are mandatory fields.  I would like to know how to only make those forms which appear visible to require the mandatory fields and the hidden forms not to require the mandatory fields be filled in.


Thank you in advance for your help.

6 Replies

Avatar

Level 10

You can check the presence property of the Subform to check whether it is visible or hidden.

     if(Subform1.presence == "hidden"){

}

If it is hidden, then make the fields inside that subform non-mandatory by setting the mandatory property.

     if(Subform1.presence == "hidden"){

           Subform1.TextField1.mandatory ="disabled";

     }

    

Hope this gives an idea..

Thanks

Srini

Avatar

Former Community Member

Im not sure what i am doing wrong. It is not working.  Do i put this in the validate event?

Avatar

Level 10

May be you can do this way..

Since you are making the Subforms visible and hidden in the click event of a checkbox, you can write the code in the same click event..

Make all the fields in the Subform non-mandatory.. (By changing the Type in Value tab as "User Entered -Optional").

In the click event you might have the code to make the subform as Visible..

After setting the subform as visible, then make the fields inside that same form as mandatory..

//In this sample code, when checkbox is checked, I am making Subform1 visible and then TextField1 and NumericField1 as mandatory.

//If I uncheck the checkbox, I am making Subform1 hidden and then TextField1 and NumericField1 as non- mandatory.

if(CheckBox1.rawValue = "1") {

     Subform1.presence ="visible";

     Subform1.TextField1.mandatory ="error";

     Subform1.NumericField1.mandatory ="error";

etc..

}

if(CheckBox1.rawValue = "0") {

     Subform1.presence ="hidden";

     Subform1.TextField1.mandatory ="disabled";

     Subform1.NumericField1.mandatory ="disabled";

etc..

}

Hope this helps..

Thanks

Srini

Avatar

Former Community Member

Still having problems...will write back tomorrow. thanks for all your help.

Avatar

Level 10

Send me the form to LiveCycle9@gmail.com so I can have a look at it..

Mention where the issue is..

Thanks

Srini

Avatar

Former Community Member

It looks like I got it to work.
Thank you very much for your help!

Nik