In Confiforms, I have a checkbox group mycbgroup with checkboxes cb1, cb2, cb3, cb4, cb5.
I am trying to make some of them work as a sub-group ... so (e.g.) if user checks/unchecks cb1, then this checks/unchecks cb3, and vice-versa.
I almost have this working using Field Definition Rules, as I know how to create a rule that turns specific checkboxes on ... by using a Set Value action as follows:
mycbgroup=[entry.mycbgroup.asList],cb1,cb3
My question, how do I write a rule that turns specific checkboxes off?
Ah, I think I found it!
mycbgroup=[entry.mycbgroup.asList.replaceWith(cb1,).replaceWith(cb3,)]
The reason this works, is that in the Set Value action, the right side of the assignment needs to be a string -- a comma-separated list of the checkboxes that should be turned on. Any checkboxes not listed are turned off.
The asList virtual function renders the field value as a comma-separated string, so that we can manipulate it.
To append more comma-separated checkbox IDs to the string, you just add them outside the square brackets following the asList.
mycbgroup=[entry.mycbgroup.asList],cb1,cb3
To remove checkbox IDs from the string, you use the replaceWith virtual function.
mycbgroup=[entry.mycbgroup.asList.replaceWith(cb1,).replaceWith(cb3,)]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You shall use ConfiForms Definition Rules with action reset value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, but what is the syntax for the set-value?
The above was my set-value syntax for turning *on* specific checkboxes, but what do you use to turn specific boxes *off*?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Reset value action to reset all in the field and then Set value to select specific
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm still not clear.
As I understand it, the Reset Value action will undo the change to the checkbox group. I.e., if the user turns cb1 off, then the action will reset it back to on. I don't want that.
What I want is: if the user turns cb1 off, then I want the rule to automatically turn cb3 off as well, while leaving the remaining checkboxes unaffected.
I know how to turn it on, using the Set Value action (set as I describe above). But I don't know what Set Value action to specify to turn cb3 (and only cb3) off.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or to put it another way, if the user turns cb1 off, and I use the Reset Value action (which turns it back to on), then I still need to know what Set Value action syntax to use to change both cb1 and cb3 to off ... while leaving the remaining checkboxes unaffected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.