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.
Capitalize Specific Field Value Before Saving Entry
Goal
By default this code snippet automatically converts the value of a specific text field to uppercase before saving the entry in Gravity Forms. It ensures consistency in formatting and is particularly useful for fields like names, codes, or identifiers that require capitalization. Now also allows numerous other text manipulations and transformations:
- Case transformations: uppercase, lowercase, title case, camelCase, PascalCase, sentence case
- Formatting: URL-friendly slugs, phone number formatting, whitespace trimming, space collapsing
- Cleaning: strip HTML tags, remove non-alphanumeric characters
- Special: string reversal
Configuration
- Edit the config block below. Installed through GOCSM, these values are fields and survive snippet updates.
BLD_CAP_FORM_ID: target form ID. Use 0 to apply to every form.BLD_CAP_FIELD_ID: target field ID. Use 0 to apply to every field on the form. Ignored when the form ID is 0.BLD_CAP_APPLY: transformations to apply, in order. Options: 'upper', 'lower', 'title', 'camel', 'pascal', 'sentence', 'slug', 'trim', 'collapse', 'alphanumeric', 'phone', 'strip_tags', 'reverse'.
Features
- Ensures uniform formatting for data consistency.
- Applies only to text input fields, preventing unintended changes to other field types.
- Easily customizable by modifying the form and field ID in the filter hook.
- Multiple transformations can be applied in sequence
- Highly configurable with 12+ built-in transformation options
- Preserves original value if transformation not applicable
- Sanitizes output for security
This code is best installed directly on your site using the Code Snippets plugin.
Loading...
Review this entry
You must be logged in to post a comment.