BrightLeaf Digital Code Snippet Library

Check out our growing library of code snippets for Gravity Forms!

Prevent selected fields on child form having the same value

GOAL

When using Nested Forms, prevent duplicate values across multiple child entries in the same batch/session for specific fields you choose (e.g., a number field, a name field, or a date field).

CONFIGURATION

  • $forms_and_fields: Add your child form ID as the key, and list the child field IDs you want to keep unique with the message users should see if they choose a duplicate.
  • Example: 66 => [ 4 => 'Please choose a unique value.', 2 => 'First and last name must be unique.' ]

NOTES

  • Name fields compare First AND Last together. If both match an existing entry, it's considered a duplicate.
  • Date fields compare dates using the site's timezone. If parsing fails, the comparison for that item is skipped.
Install Using Code Snippets

This code is best installed directly on your site using the Code Snippets plugin.

Check Out the Code

Loading...

Code Copied!
Stay Updated On This Snippet

This entry has no reviews.