Home Forums Bug Reports DateTimePicker cannot be set to Read Only


DateTimePicker cannot be set to Read Only

  • I have tried unsuccessfully to set a field to either “diabled” or “readonly” on a front-end form using either the load_field and prepare_field filter hooks. The picker still funtions and saves the value on submit.

    I am confident that my function is working because I can convert the field type to text and it is readonly on the form.

    I think this may be a bug related to a Jquery conflict.

    Any feedback would be appreciated.

  • This is related to the version of Select2 being used. The developer is working on this but updating the version of Select2 comes with creates several issues that need to be corrected. It is on the developer’s to do list.

  • Why do you need to make the field readonly or disabled? Maybe there is another solution.

  • Hey, thanks for the response. I am using a date picker to set date/time on a frontend form by the Admin, but if not Admin I dynamically set the field to read-only for subscriber/user so they can’t change the date. Currently I’ve elected to just use a text field, but the picker function would have been nice.

  • I don’t really have an easy solution for you.

    You could look into adding your own custom JavaScript to try and make the field readonly. The problem is that the version of Select2 used currently in ACF is “Not Aware” of fields being readonly or disabled. I don’t even know if this is solvable.

    You can also dynamically change the field type depending on the status of the logged in user, but that’s not likely to help you either since internally dates are stored in the format YYYYMMDD and showing that in a text field would probably just confuse people.

    Another choice is to have two different fields, one for admins and one for everyone else. When the admin updates the value in the admin field you could dynamically populate the other field using an acf/save_post filter ( and the update_field() function ( I have recently created a plugin that let’s you create fields for specific user roles. If you didn’t want to use the plugin and just set it up on a single field you can use it as an example.

  • Hi,

    Has there been any update on this issue?
    It seems it’s still not possible to set a datetime field to read only.

    Trying to find a workaround based on John’s suggestions.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.