AdvancedCustomFields / AdvancedCustomFields/acf
Gutenberg compatibility for PHP/AJAX Validation
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 945
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
Description
A highly used feature in ACF is our PHP validation powered via AJAX. This allows developers to highly customize the validation process via PHP whist providing convenient feedback to the user when a field value does not meet its requirements.
To do this, we use JS to intercept the "submit" action on the form and stop it. We then send all $_POST data via an AJAX request and use the returned JSON to either display errors or re-submit the form.
It is important for UX that we validate the form data only when the user clicks the "publish" button.
Issues
- The form "submit" event is never fired, so our AJAX validation is never triggered.
Questions
- What can we "hook" into to prevent the post from being submit in order to validate via AJAX and then re-submit?
- How can we get all the $_POST data about the post (title, content, etc)?
- How can we re-submit the form after validation is complete?
- Is there an API for displaying an error message in Gutenberg?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start by tracing Gutenberg's publish flow and comparing it with ACF's JavaScript submit interception and PHP AJAX validation described here. Done would require a confirmed hook for publish, access to the post data, validation-aware resubmission, and an error-display API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, php, wordpress
- Domain
- api, backend, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100