I have a page with a front-end acf_form(). When I click Update, the little spinner appears and the page refreshes with the query variables. All great so far. But, to tie it in more closely with my design, I’d like to trigger my full-page visual loader when the Update button is clicked.
…but if there’s an error (for example, the field/checkbox is required), I want to hide that full-page loader with showLoadingBlocker(false), but I can’t figure out how. I was wondering if there’s a custom trigger that gets fired when an acf_form() encounters an error, or any other event?
Potentially I could add a DOM Mutation Observer to listen for error classes in the button’s parent form, but it seems like overkill when listening for a trigger would be much more straightforward, if possible.
You can probably look in json.errors to see if there was an error. There isn’t anything on the JS side of things that will be triggered after the page is submitted and the fields are updated. All of the update process happens in PHP
You can potentially add a url query variable in to the acf return value in acf_form() and then have a ready event that looks for that value to determine what to do next. Or you could create an acf/save_post action and hijack the redirect and do your own redirect before ACF does it’s thing.