Saltar navegación

[Resuelto] Placeholder address field cred not working

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:

A user reported that the 'placeholder' attribute for the 'cred_field' shortcode, doesn't seem to work for the address type fields.

Solution:

Guided that I've passed this on to the concerned team and for now a workaround can be to use the 'gettext' filter to change that default placeholder text.

Relevant Documentation:

https://developer.wordpress.org/reference/hooks/gettext/

This support ticket is created hace 2 años, 9 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por smileBeda hace 2 años, 9 meses.

Asistido por: Waqar.

Autor
Mensajes
#2323517
Screenshot 2022-03-22 at 08.45.01.png

I am trying to:
Using [cred_field field='user-geolocation' force_type='field' class='form-control' output='bootstrap' placeholder='Enter Location']

I expected to see:
Placeholder in the address input changed to "Enter Location" instead of "Enter Address"

Instead, I got:
"Enter Address" both in visual and HTML part, see screenshot.

#2323803

Hi Beda,

Hope you're well.

I was able to reproduce this behavior on my test website too. The 'placeholder' attribute for the 'cred_field' shortcode, doesn't seem to work for the address type field.

I've passed this on to the concerned team and for now a workaround can be to use the 'gettext' filter to change that text:
https://developer.wordpress.org/reference/hooks/gettext/

For example:


add_filter( 'gettext', 'custom_address_field_placeholder', 20, 3 );
function custom_address_field_placeholder( $translated_text, $text, $domain ) { 
    switch ( $translated_text ) {
        case 'Enter address' :
            $translated_text = __( 'Some other text', 'toolset-maps' );
        break;
    }
    return $translated_text;
}

regards,
Waqar

#2324799

I have already had solved it with JS, get text calls are not best in performance, so I don't prefer that solution.

If anyone needs it, I used:

var placeholder = jQuery("input[name*='WPCF_FIELD_SLUG']");
if( ! jQuery( placeholder ).val() ) { 
    jQuery( placeholder ).attr("placeholder", "YOUR CUSTOM VALUE");
}