Add_filter( 'gform_required_legend', '__return_empty_string' );....doesn't work for me

Can someone please help me.
I placed it the functions.php file of my child theme.
And i cannot figure out where it goes wrong (i am also not so experienced in this)

Thank you

Hello Milco,

I was unable to get the code to work too, but the code itself is fine. It seems like the issue might be elsewhere. It could be a bug in the current version of the GF. For now, you can remove the “Required” text by using custom CSS.

Try the following CSS code in the child theme’s style.css file or in Appearance → Customize → Additional CSS .

.gfield_required.gfield_required_text {
    display: none;
}

Let me know how this works.

stil no luck.
thank you for your help.
any other ideas?

Hi Milco,

Sorry to hear it did not work.

May I have the URL where can see the form live so can assist you more precisely?

Thanks

https://staging.aprilworks.nl/over-april/

Thank you for giving the URL.

You can use this CSS

.gfield_required.gfield_required_asterisk {
    display: none !important;
}

It will look like this

Let me know how it works.

Thanks

Hi Akramul,

Thank you for your help.

This last piece of css only removes the aterisk. The text is still visible.

Why is this so hard to remove? I can imagine a lot of gravity users don’t want this text, or want is in another language.

Again,

Thank you for your help and patience.

Met vriendelijke groet,

Milco Pot

Amici Consulting

06 – 28 455 904

Title: LinkedIn - Description: image of LinkedIn icon

Hello Milco,

Sorry it’s my fault! Its not too hard to remove by CSS, but I have overlooked this text.

Here is the updated CSS.

.gform_required_legend,
.gfield_required.gfield_required_asterisk {
    display: none !important;
}

Let me know how this works.

Regards,

YES,

Perfect.

Thank you so much.

Do you happen to have a css code for changing the text as well? For if I want the required text in another language?

Thanks

Met vriendelijke groet,

Milco Pot

Amici Consulting

06 – 28 455 904

Title: LinkedIn - Description: image of LinkedIn icon

That’s great to hear.

If you want to change the text language, we can do it by using custom Javascript code. If you can leave the details here, I will do it for you.

Thanks.

Hey Milco,

  1. To change the text “*” indicates required fields to a custom text, use the following code in your child theme’s functions.php file or a Code Snippets plugin. Make sure to replace the text within the function below.
add_filter( 'gform_required_legend', function( $legend, $form ) {
    return 'your custom legend here';
}, 10, 2 );

  1. To change the required fields indicator, navigate to Forms Settings → Required Field Indicator and choose the Custom option to insert your own text, as shown in the screenshot below.

:warning: Note: These are the recommended ways to modify these settings without encountering any issues in the future.

Final preview:

:link: Useful Resources:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.