We were wondering if there would be a way to disable the "+Add" button, on a collection, based on a choice selected on another field? We are trying to set it up so if a specific radio button option is selected (individual), only one collection set would be available, whereas if another radio button is selected (group), one or more collection sets would be available.
I found this post that includes code to turn off this ability, however including this in CSS, in Designer Mode, didn't appear to work. I also tried applying the idea in this post to a collection (changing the number to match the collection field ID, and using cf-collection-append, as follows:
#q9 .cf-collection-append {
display: none !important;
}
(#q9 {display: none !important;} hides the entire collection, so I know we're getting close...)
(Of course, even if I was able to get the above working, I would ultimately need to place it in an IF statement, based on the value for the radio button selected.)
Thank you to anyone who chooses to assist us with this! ![]()
Marty Gaffney - Network Analyst
Town of Okotoks
Question
Question
Can you disable a collection set from being added based on a field choice?
Answer
Unfortunately your links are for classic designer. That's why your CSS isn't working. A bigger problem you'll run into when you fix this is if the user can flip between individual/group in that radio you don't want to automatically clear their fields.
Try this:
1. Add this CSS:
.hide-new-row {
.table-row-add,
.collection-set-add {
display: none;
}
}
2. Select the collection (not a field inside the collection) and add a field rule
"one or more" is your individual or group radio button
Now you'll have a problem validating the collection only has one row when individual is selected.
3. Add a new number field to the collection.
Name it "rownum" and make it readonly then hide it with field rules, make sure to select save data when hidden.
Under advanced, use the formula "ROW()"
4. Add a new number field to the form.
Make it readonly.
Under advanced, use a formula like "COUNT(Collection.rownum)" to get the row count of the table.
5. Validate the number field outside the collection is 1 only when your radio is individual
6. Add a custom error message to the number field outside the collection so the validation is more intuitive
Should there just be a field rule that says validate table/collection as having N rows when some condition is met. Probably haha, but you have more control over the behavior this way.
Thought I'd better report back - my coworker tried setting this up exactly like you laid out above, and it appears to be working as expected.
Thanks so much for your assistance!
Marty