• Resolved Richard

    (@richardelovia)


    Hi,

    I’m using some forms with datepicker field in order to let users to input dates. Problem is that the field is being covered by keyboard when user from smartphone.

    I’ve found an old thread where you provided a snippet for a mu-plugin. The snippet was the following:

    <?php
    

    add_filter( ‘forminator_field_date_markup’, function( $html, $field ) {

    if ( isset( $field[ ‘custom-class’ ] ) && strpos( $field[ ‘custom-class’ ], ‘readonly’ ) !== false ) {
    $html = str_replace( ‘type=”text”‘, ‘type=”text” readonly’, $html );
    }

    return $html;

    }, 20, 2 );

    I’ve correctly installed the mu-plugin and I can see it in the must use list of my wordpress installation. However the code seems to not work and I was wondering if that snippet can be used nowadays. I have the need to set add the readonly attribute to that field.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @richardelovia

    I hope you are doing good today.

    I have made a test on my lab site and it seems the code is not valid anymore. I pinged our SLS Team to review your query. We will post an update here as soon as more information is available.

    Kind Regards,
    Kris

    Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi again @richardelovia

    Our SLS has made multiple tests and it seems the code is valid and my test was incorrect.

    Please double-check both things:
    – after adding code as mu-plugin, clear site cache and any server-side cache
    – CSS class for your datapicker should be “readonly”, not “custom-class”

    Kind Regards,
    Kris

    Thread Starter Richard

    (@richardelovia)

    Thank you a lot @wpmudevsupport13 ! It is working like a charm!

    Have a great day,
    Best regards!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Make datepicker field readonly’ is closed to new replies.