AdvancedCustomFields / AdvancedCustomFields/acf

Cannot disable a datepicker field manipulating $field

Open
#26 13 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hello everyone!

I was trying to disable some fields according the clean way suggested by the documentation:

function my_acf_prepare_field( $field ) {
	if( $field['value'] ) {
		$field['disabled'] = true;
	}
    return $field;
}

But I noticed that this code doesn't work (it's still possible to interact with the field) on the datepicker field (the same is true also datetime picker). I dug a bit into the code and I realized that, simply, the disabled attribute is not honored because there's not code that makes use of it.

Since it's quite trivial to solve, I'm about to submit a small pull request. :)

Have a nice day!

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 by tracing how the datepicker and datetime picker fields render their controls, using the reported disabled-field behavior as the entry point. Confirm that fields disabled through the PHP hook can no longer be interacted with for both picker types, and verify the result against any relevant project checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.