Skip to content

Instantly share code, notes, and snippets.

@matty0501
Created June 24, 2024 14:36
Show Gist options
  • Save matty0501/ddb10a7e8da961da68434418c995823f to your computer and use it in GitHub Desktop.
Save matty0501/ddb10a7e8da961da68434418c995823f to your computer and use it in GitHub Desktop.
<?php
/**
* Gravity Perks // Nested Forms // Add `Required` label to Nested Form field
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*
* Adds a `Required` label to a Nested Form field when a minimum child entry limit is set.
*/
// Replace `123` with your form ID and `4` with your Nested Form field ID
add_filter( 'gform_field_content_123_4', function ( $content, $field, $value, $lead_id, $form_id ) {
if( $field->gpnfEntryLimitMin > 0 ){
$content = str_replace ( $field->label, $field->label. '<span class="gfield_required">' . GFFormsModel::get_required_indicator( $form_id ) . '</span>', $content );
}
return $content;
}, 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment