Hidden and required fields

NumenoreanX

18-01-2018

Adobe Livecycle ES2 V. 9.0.0.2

I've created a dynamic form with 4 identical subforms that toggle based upon selection of a dropdown list. Each subform is a week, and the dropdown list is supposed to select how many of these subforms appear (if 2 is selected, then 2 of these subforms appear, etc...)

NOW - There are required fields in this subform that I learned early on would remain required even after said subform was hidden due to selection of the dropdown.

I have scoured the forums for ways around this and have been unable to get any listed methods to work.

I came up the following code in an effort to "de-toggle" the mandatory field IF the subform gets changed to hidden. This works for changing the required fields to no longer mandatory once the field is hidden. However it also has the side effect of hiding the form, even if I have otherwise toggled it "visible" through other scripts; this one script overrides all others and hides 3 of my subforms :

if (form1.page1.subform2.presence = "hidden") {

form1.page1.subform2.relaventfield1.mandatory = "disabled"

form1.page1.subform2.relaventfield2.mandatory = "disabled"

form1.page1.subform2.relaventfield3.mandatory = "disabled"

etc...

}

There are ~15 fields that I list in the above manner, and I have 3 of these script sets, one for each subform (there will always be at least 1 subform present no matter the dropdown selection).

I've tried placing this in various areas in the form, and under various events (exit, presubmit, change, etc..) The result is always the same, other than when the script triggers.

The question is why is this hiding my subforms? I'm sure there may be a better way to do this but I am not fluent in javascript. Any tips?

Accepted Solutions (1)

Accepted Solutions (1)

NumenoreanX

18-01-2018

Alright - I got it (the code working, still no clue why the above "if" statement was hiding my subforms).

To accomplish what I needed to I combined my code under the exit event for the drop down list where I toggled between 1-4 (as explained above). I put together my code to toggle subforms hidden/visible based on the drop down selection and the code to toggle mandatory field based on presence of subforms. I removed the "if" statement regarding the presence state of the subforms, this stopped the form from incorrectly hiding my subforms.

I'm sure this is horribly inefficient, but it works PERFECTLY and is simple, so anyone can replicate it.

To explain to anyone else trying to do this : presence hidden/visible will toggle a field hidden or visible. Mandatory disabled/error will toggle a field no required or user required (respectively)

if (form1.Page1.Header.Weeks.rawValue == 1){
form1.Page1.Week2Subform.presence = "hidden"
form1.Page1.Week2Subform.Monday.Coverage.mandatory = "disabled"
form1.Page1.Week2Subform.Monday.Availability.mandatory = "disabled"
form1.Page1.Week2Subform.Tuesday.Coverage.mandatory = "disabled"
form1.Page1.Week2Subform.Tuesday.Availability.mandatory = "disabled"
form1.Page1.Week2Subform.Wednesday.Coverage.mandatory = "disabled"
form1.Page1.Week2Subform.Wednesday.Availability.mandatory = "disabled"
form1.Page1.Week2Subform.Thursday.Coverage.mandatory = "disabled"
form1.Page1.Week2Subform.Thursday.Availability.mandatory = "disabled"
form1.Page1.Week2Subform.Friday.Coverage.mandatory = "disabled"
form1.Page1.Week2Subform.Friday.Availability.mandatory = "disabled"
form1.Page1.Week3Subform.presence = "hidden"
form1.Page1.Week3Subform.Monday.Coverage.mandatory = "disabled"
form1.Page1.Week3Subform.Monday.Availability.mandatory = "disabled"
form1.Page1.Week3Subform.Tuesday.Coverage.mandatory = "disabled"
form1.Page1.Week3Subform.Tuesday.Availability.mandatory = "disabled"
form1.Page1.Week3Subform.Wednesday.Coverage.mandatory = "disabled"
form1.Page1.Week3Subform.Wednesday.Availability.mandatory = "disabled"
form1.Page1.Week3Subform.Thursday.Coverage.mandatory = "disabled"
form1.Page1.Week3Subform.Thursday.Availability.mandatory = "disabled"
form1.Page1.Week3Subform.Friday.Coverage.mandatory = "disabled"
form1.Page1.Week3Subform.Friday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.presence = "hidden"
form1.Page1.Week4Subform.Monday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Monday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Tuesday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Tuesday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Wednesday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Wednesday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Thursday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Thursday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Friday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Friday.Availability.mandatory = "disabled"
}

if (form1.Page1.Header.Weeks.rawValue == 2){
form1.Page1.Week2Subform.presence = "visible"
form1.Page1.Week2Subform.Monday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Monday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Tuesday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Tuesday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Wednesday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Wednesday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Thursday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Thursday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Friday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Friday.Availability.mandatory = "error"
form1.Page1.Week3Subform.presence = "hidden"
form1.Page1.Week3Subform.Monday.Coverage.mandatory = "disabled"
form1.Page1.Week3Subform.Monday.Availability.mandatory = "disabled"
form1.Page1.Week3Subform.Tuesday.Coverage.mandatory = "disabled"
form1.Page1.Week3Subform.Tuesday.Availability.mandatory = "disabled"
form1.Page1.Week3Subform.Wednesday.Coverage.mandatory = "disabled"
form1.Page1.Week3Subform.Wednesday.Availability.mandatory = "disabled"
form1.Page1.Week3Subform.Thursday.Coverage.mandatory = "disabled"
form1.Page1.Week3Subform.Thursday.Availability.mandatory = "disabled"
form1.Page1.Week3Subform.Friday.Coverage.mandatory = "disabled"
form1.Page1.Week3Subform.Friday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.presence = "hidden"
form1.Page1.Week4Subform.Monday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Monday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Tuesday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Tuesday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Wednesday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Wednesday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Thursday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Thursday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Friday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Friday.Availability.mandatory = "disabled"
}

if (form1.Page1.Header.Weeks.rawValue == 3){
form1.Page1.Week2Subform.presence = "visible"
form1.Page1.Week2Subform.Monday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Monday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Tuesday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Tuesday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Wednesday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Wednesday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Thursday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Thursday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Friday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Friday.Availability.mandatory = "error"
form1.Page1.Week3Subform.presence = "visible"
form1.Page1.Week3Subform.Monday.Coverage.mandatory = "error"
form1.Page1.Week3Subform.Monday.Availability.mandatory = "error"
form1.Page1.Week3Subform.Tuesday.Coverage.mandatory = "error"
form1.Page1.Week3Subform.Tuesday.Availability.mandatory = "error"
form1.Page1.Week3Subform.Wednesday.Coverage.mandatory = "error"
form1.Page1.Week3Subform.Wednesday.Availability.mandatory = "error"
form1.Page1.Week3Subform.Thursday.Coverage.mandatory = "error"
form1.Page1.Week3Subform.Thursday.Availability.mandatory = "error"
form1.Page1.Week3Subform.Friday.Coverage.mandatory = "error"
form1.Page1.Week3Subform.Friday.Availability.mandatory = "error"
form1.Page1.Week4Subform.presence = "hidden"
form1.Page1.Week4Subform.Monday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Monday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Tuesday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Tuesday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Wednesday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Wednesday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Thursday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Thursday.Availability.mandatory = "disabled"
form1.Page1.Week4Subform.Friday.Coverage.mandatory = "disabled"
form1.Page1.Week4Subform.Friday.Availability.mandatory = "disabled"
}

if (form1.Page1.Header.Weeks.rawValue == 4){
form1.Page1.Week2Subform.presence = "visible"
form1.Page1.Week2Subform.Monday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Monday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Tuesday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Tuesday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Wednesday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Wednesday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Thursday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Thursday.Availability.mandatory = "error"
form1.Page1.Week2Subform.Friday.Coverage.mandatory = "error"
form1.Page1.Week2Subform.Friday.Availability.mandatory = "error"
form1.Page1.Week3Subform.presence = "visible"
form1.Page1.Week3Subform.Monday.Coverage.mandatory = "error"
form1.Page1.Week3Subform.Monday.Availability.mandatory = "error"
form1.Page1.Week3Subform.Tuesday.Coverage.mandatory = "error"
form1.Page1.Week3Subform.Tuesday.Availability.mandatory = "error"
form1.Page1.Week3Subform.Wednesday.Coverage.mandatory = "error"
form1.Page1.Week3Subform.Wednesday.Availability.mandatory = "error"
form1.Page1.Week3Subform.Thursday.Coverage.mandatory = "error"
form1.Page1.Week3Subform.Thursday.Availability.mandatory = "error"
form1.Page1.Week3Subform.Friday.Coverage.mandatory = "error"
form1.Page1.Week3Subform.Friday.Availability.mandatory = "error"
form1.Page1.Week4Subform.presence = "visible"
form1.Page1.Week4Subform.Monday.Coverage.mandatory = "error"
form1.Page1.Week4Subform.Monday.Availability.mandatory = "error"
form1.Page1.Week4Subform.Tuesday.Coverage.mandatory = "error"
form1.Page1.Week4Subform.Tuesday.Availability.mandatory = "error"
form1.Page1.Week4Subform.Wednesday.Coverage.mandatory = "error"
form1.Page1.Week4Subform.Wednesday.Availability.mandatory = "error"
form1.Page1.Week4Subform.Thursday.Coverage.mandatory = "error"
form1.Page1.Week4Subform.Thursday.Availability.mandatory = "error"
form1.Page1.Week4Subform.Friday.Coverage.mandatory = "error"
form1.Page1.Week4Subform.Friday.Availability.mandatory = "error"
}

Answers (0)