Learn how to fix Divi footer not showing or updating issues in WordPress. Easy steps to troubleshoot and solve footer problems fast.
How to Customize Required Field Legend in Gravity Forms

Table of Contents
Here’s your Table of Contents with clickable links:
- Introduction
- Why Customize the Required Field Legend?
- Method 1: Change the Default Required Field Text via Settings
- Method 2: Customize Using CSS
- Method 3: Modify Using PHP Filter
- Where to Add the Code?
- Testing Your Customization
- FAQ
Introduction
Gravity Forms is a powerful WordPress plugin that helps users create custom forms. By default, it displays a generic required field legend, but you can modify it for better user experience.
Why Customize the Required Field Legend?
Customizing the legend makes forms clearer for users, ensuring they understand which fields are mandatory. This can improve form completion rates and usability.

Adding Custom Code to Gravity Forms
You can use a WordPress filter hook to modify the required field legend. The gform_required_legend
filter allows you to replace the default text.

Method 1: Change the Default Required Field Text via Settings
To customize the required field legend in Gravity Forms without coding, follow these steps:
- Navigate to Forms → Settings in your WordPress admin panel.
- Locate the Required Field Indicator section.
- Modify the text to your preferred message (e.g., “Fields with () are mandatory”*).
- Save changes.

Method 2: Customize Using CSS
You can hide the default legend and add your custom text via CSS:
.gform_required_legend {
display: none;
}
Then, manually add the following custom text above your form in an HTML block:
Method 3: Modify Using PHP Filter
Use the following PHP function to modify the required field legend for a specific form (e.g., Form ID 1):
function custom_gform_required_legend($legend, $form) {
if ($form['id'] == 1) {
return 'Required fields are marked with an asterisk (<span class="gfield_required gfield_required_asterisk">*</span>).';
}
return $legend;
}
add_filter('gform_required_legend', 'custom_gform_required_legend', 10, 2);
Where to Add the Code?
Add this code to your WordPress theme’s functions.php
file or use a custom plugin for better management.
Testing Your Customization
After adding the code, check your form to ensure the required field legend displays correctly. If not, clear the cache and test again.
FAQ
Can I apply this to all forms?
Yes! Remove the form ID condition to apply it globally.
What if the legend doesn’t change?
Make sure your theme supports Gravity Forms hooks and check for conflicting plugins.
Can I style the legend differently?
Yes! Use CSS to customize the appearance of the required field legend.
This Post Has 0 Comments