This PRO option is available since version 1.9.15
If you add the disable_on_hide
attribute to a group, all the fields within that group will be disabled when the group is hidden.
As per the HTML specs, a disabled field will never be submitted.
When should I use disable_on_hide?
By default, it is a very bad idea to submit a form with multiple fields that share the same name. As a work-around, you can design your form so that fields with the same name will never be visible at the same time.
With CF Free or pre-1.9.15 versions of CF Pro, all fields will be submitted. If, however, you have a good reason to exclude certain fields from being submitted when they are not visible, you can put them inside a group with the disable_on_hide attribute.
Example
In the example below we have 2 fields named state
. But, by using disable_on_hide
and by making sure that both fields will never appear at the same time, there is no need to make the field names unique.
Form
Form Code
[radio country use_label_element "US" "Canada"]
[group state-us disable_on_hide]
[select state "Alaska" "Oklahoma"]
[/group]
[group state-canada disable_on_hide]
[select state "Alberta" "BC"]
[/group]
[submit]
Conditional Fields (Text)
show [state-us] if [country] equals "US"
show [state-canada] if [country] equals "Canada"