BrightLeaf Digital Code Snippet Library
Check out our growing library of code snippets for Gravity Forms!
Eleven of these snippets register their own shortcodes. Every tag and attribute is in our Gravity Forms shortcodes reference. Need a Gravity Forms or GravityView shortcode built for you? Try the free shortcode builder.
Disable Choices Already Picked in a Dropdown on Nested Form by Another Child Entry in the Batch
Goal
This JavaScript snippet disables dropdown choices in a Gravity Forms nested form to prevent duplicate selections across child entries within the same batch. When a user selects an option in one child entry, it becomes unavailable in subsequent child entries, ensuring unique selections. JS snippet to be installed on child form. Make sure to replace the parent form id, the field id of the dropdown and the field id of the nested form on the parent form.
Configuration
- Edit the config block below. Installed through GOCSM, these values are fields and survive snippet updates.
bldNestedParentFormId: ID of the parent form that contains the Nested Form fieldbldNestedFieldId: Field ID of the Nested Form field on the parent formbldNestedChildDropdownFieldId: Field ID of the dropdown on the child formbldNestedCompareBy: 'value' (recommended) or 'label' to compare against saved values or visible labels
Features
- Prevents duplicate selections in a dropdown field within nested forms.
- Dynamically disables options that have already been chosen by other child entries.
- Works within the same batch of child entries in a Gravity Forms parent form.
- Ensures data integrity by restricting users from selecting the same option multiple times.
- Customizable field IDs to match your specific form setup.
- Lightweight and efficient JavaScript solution that runs client-side.
Notes
- Adds class 'bld-disabled-choice' to disabled and sets a helpful title.
This code is best installed directly on your form using the Code Chest plugin.
Loading...
Review this entry
You must be logged in to post a comment.