Created
August 7, 2026 08:41
-
-
Save esedic/a36b44705fccf6cbe0c22802545e8386 to your computer and use it in GitHub Desktop.
Display Field IDs Next to Field Labels in the Gravity Forms Editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Gravity Wiz // Gravity Forms // Display Field IDs Next to Field Labels in the Editor | |
| * https://gravitywiz.com/ | |
| * | |
| * Experimental Snippet 🧪 | |
| * | |
| * Instruction Video: https://www.loom.com/share/0268993d0b6c429ba50686bd740093bc | |
| * | |
| */ | |
| add_filter( 'gform_field_content', function( $content, $field ) { | |
| if ( ! GFCommon::is_form_editor() ) { | |
| return $content; | |
| } | |
| static $_gw_inline_field_id_style; | |
| if ( ! $_gw_inline_field_id_style ) { | |
| $content .= ' | |
| <style> | |
| .gw-inline-field-id { | |
| background-color: #ecedf8; | |
| border: 1px solid #d5d7e9; | |
| border-radius: 40px; | |
| font-size: 0.6875rem; | |
| font-weight: 600; | |
| padding: 0.1125rem 0.4625rem; | |
| margin-bottom: 0.5rem; | |
| display: inline-block; | |
| vertical-align: middle; | |
| } | |
| </style>'; | |
| $_gw_inline_field_id_style = true; | |
| } | |
| $search = '<\/label>|<\/legend>'; | |
| $replace = sprintf( '\0 <span class="gw-inline-field-id">ID: %d</span>', $field->id ); | |
| $content = preg_replace( "/$search/", $replace, $content, 1 ); | |
| return $content; | |
| }, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment