Hello to all,
I’ve been stuck on this for 2 days now… Indeed, I want to modify the template file acf-field-functions.php in the includes folder of the plugin by overloading it in my child theme. Unfortunately, after following the documentation Including ACF within a plugin or theme and testing a lot of things, I can’t override the acf_get_field_label function of the template in my child theme, even with the add_action in the functions.php file of my theme.
Can you help me and explain me the procedure to modify the acf_get_field_label function of the acf-field-functions.php template in my child theme ?
Thanks in advance.
You cannot override ACF functions.
ACF provides a filter for altering the results of this function, you can see it in that function.
$label = apply_filters( 'acf/get_field_label', $label, $field, $context );
Hello John,
Can you tell me how to change the required HTML <span class="acf-required">*</span>
or remove it with this filter ?
And can you tell me how I can modify the labels of the error messages when submitting the form without being able to overload a function ?
Thank you very much for your reply.
You can’t remove <span class="acf-required">*</span>
. You need ot make the field not required or use custom CSS to hide it.
Changing error messages requires using JS. see https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/ and https://www.advancedcustomfields.com/resources/javascript-api/ I don’t have any examples. You might find something here or on similar topics https://support.advancedcustomfields.com/forums/topic/acf_form-with-custom-validation-message/