Home › Forums › Front-end Issues › How to validate fields on the same page when using acf_form() › Reply To: How to validate fields on the same page when using acf_form()
So this took quite a lot of effort to figure out. Turns out
acf_form_head() it needs to be before any output but if you do it too soon it causes all sorts of errors. I thought using WP’s init hook would work, and it did for the most part, but it would break AJAX validation (hence the middle page).
I tried a few different hooks but it seems like
template_include is the one that fixed the issue.
If you’re getting a 500 error page when an field is blank but the rest seems to work properly, try changing where your
acf_form_head() function is called.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.