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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.