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.

Question about making mandatory fields hidden

Avatar

Level 4
If I make an empty mandatory field hidden, do I have to set the mandatory property to "disabled" to prevent it from triggering the error message since it's empty?
6 Replies

Avatar

Former Community Member
If it is hidden it is not part of the layout so no it will not be included in the validation check when a submit is fired.

Avatar

Level 4
Hmm, I hid some fields that would otherwise be required and I get the validation script message on execValidate().

Avatar

Level 4
Oooh, didn't see this post before.



I get the same problem with the execValidate() for hidden fields. I've got a lot of script in my form to dynamically set the mandatory status as I do a lot of hiding.



Tom

Avatar

Former Community Member
You are calling it a problem and I say works as designed. When you make a field mandatory you are indicating that the field must have a value (in the data file). When the submit is pressed, the mandatory fields are checked and if a value for that field is not in the data dom (in the bound node) then the message s displayed (whether the field is visible or not the binding still exists). You should make the field not mandatory by default, then make it mandatory when you make it visible.

Avatar

Level 4
I don't know that it's a problem as long as it works consistently, which it does. It's easy enough, if soemwhat laborious, to set the fields in question to disabled when they are hidden. It would be kind of nifty if one could set all the fields in a subform or table either mandatory or disabled at the subform or table level as well as at the individual field level.



No worry, I just wanted to make sure I understood it before I started twiddling with the form.

Avatar

Level 4
Hehe, sorry Paul. Problem probably not the right word to use for you. How about:



I get the same results with the execValidate() for hidden fields. I haven't found an easy solution to this so I've got a lot of script in my form to dynamically set the mandatory status as I do a lot of hiding.



Sound better Paul? I think it is more accurate now! :)



Tom