AdvancedCustomFields / AdvancedCustomFields/acf

Date time picker readonly field can still be changed

Open
#976 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

Date time picker readonly fields can still be changed and saved.

To Reproduce
Steps to reproduce the behavior:

  1. Add a Date Time Picker field
  2. Set it to readonly whatever the way
  3. Click on the field, datepicker shows (jquery ui component)
  4. Change the date
  5. Save
  6. You have been able to change and save a readonly field :/

Expected behavior

Honor readonly field attribute, even when a JS widget enhances it.

Screenshots or Video

https://github.com/user-attachments/assets/d13c5724-801b-4580-9ccc-7f39d80e626b

Code
Please drag and drop an export of your field group, option page, custom post type or taxonomy JSON here.
If your issue relates to ACF Blocks, please also provide a reproducable code example of your ACF Block including it's block.json so we can reproduce the issue.

Version Information:

  • WordPress Version 6.8.2
  • PHP Version 7.4
  • ACF Version Pro 6.5.1
  • Browser Chrome 140

Additional context

I would have kindly debugged that and submitted a Pull Request for this if only you provided the unminified version of your assets 🙄 (Ping #938).

BTW, this is an easy fix:

// In date picker initialize
beforeShow: function(input) {
    if ($(input).attr('readonly') || ) {
        return false;
    }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the date picker initialization mentioned in the issue and reproduce the six listed steps with a readonly field. Confirm that the jQuery UI widget cannot change or save the value when readonly, then verify the same behavior in the browser after the fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.