Home › Forums › Backend Issues (wp-admin) › WP 3.9 Validation Failed disables Publish button
This is an issue happening in WP 3.9. If a custom field is required and you try to publish the post without the required field, the error message appears as usual (“Validation Failed. One or more fields below are required.”) but the “Publish” and “Save Draft” buttons changed to a disabled state, preventing from update the field and save the post.
I’ve noticed the same thing. This is a show-stopper for me, so, for the time being, I’ve put the following workaround in my functions file. It just removes the ‘disabled’ class from the ‘Publish’/’Update’ button as soon as it’s added, which allows you to click it.
// There is a bug with ACF 4.3.7 and WP 3.9 that disables the 'Save Draft'/'Publish' button if there are validation errors. This is a dirty workaround for that bug: we remove the 'disabled' class from the button every time the button gets clicked (which adds that class to prevent spurious submits).
function load_javascript_on_admin_edit_post_page() {
global $parent_file;
// If we're on the edit post page.
if ($parent_file == 'post-new.php' ||
$parent_file == 'edit.php') {
echo "
<script>
jQuery('#publish').on('click', function() {
jQuery.this.removeClass('disabled');
});
</script>
";
}
}
add_action('in_admin_footer', 'load_javascript_on_admin_edit_post_page');
I am having this same issue. But I cannot get Matthew’s solution to work. I think it’s because I am using custom post types, not sure. Any ideas how I can get the publish button to work?
Overbound, that if statement may be causing the JavaScript not to be injected in your admin footer. Can you use View Source or the Developer Tools inspector to check? If it’s not loading, try just removing the if statement. You’ll get JS errors where that button can’t be found (on pages that are the post edit page), but it should work.
Yeah that did it! I do not have a very good understanding of the WP API or php for that matter. But I assume that custom posts must not use post-new.php or edit.php?
Oh and thank you very much for your help. =)
I’m not sure exactly. I don’t have time to dig into it right now, but I assume this bug will be fixed in ACF shortly so it should be unnecessary soon. 🙂
I’m also using Custom Post Types (CPT UI) and get this same issue on 3.9 even after trying to add Matthew’s hack above.
TheBlogHouse: Have you tried removing the if statement and just loading that JavaScript on all admin pages?
I can also confirm this bug. Thanks for the temporary fix Matthew.
Yep…ditto here, same bug. And yes….thank you Matthew for the temp fix.
Elliot…thanks so much for your attention to this, but I’m afraid that after updating to 4.3.8, I’m still seeing the issue on my site. In my case, this is a required image field.
If I try to save without an image, I’m prompted to pick one, but then after doing so….I remain unable to save the post.
Thank you for all of your hard work on ACF…it is an amazing plugin.
Thanks for the fix Matthew, I had to remove the if statement like Overbound.
Interesting to note that it’s also a bug for ACF field groups as well! e.g. if you’re on /wp-admin/post-new.php?post_type=acf and hit Publish without first giving the group a name it disables the Publish button.
Elliot: I’ve got version 4.3.8 like rpetersnmt also — the fix doesn’t seem to be in effect. Adding a new field group and hitting Publish is a quick test 🙂
Hello sir, I am newbie in wordpress. I am facing the same problem, on page updating using acf.
Where I have to put that code Matthew sir.
@rashed You can put this code in your functions.php file, which acts like a plugin that is automatically loaded for the current WordPress theme (more info).
If this problem is happening for you, though, I would definitely recommend starting a support ticket with ACF, since this particular forum post is almost five years old and might be a completely different issue. 🙂
I am using wordpress 5.0.3. I put this code functions.php but it’s having same issue.
I tried to dynamic footer section, after then I am facing this problem.
But it’s working for the other pages, where I also used acf. Only the home page showing this error.
@rashed I’m unclear exactly what the issue is; can you provide a more detailed explanation of what is going wrong? Maybe a screenshot with more context, or multiple screenshots?
When I clicked update it’s showing this error. Just only for home page. Other pages working fine.
I also checked whether required fields empty on not. But every required field is filled.
This page update worked fine before trying to dynamic footer. But I didn’t find any issue in footer.
I’m not sure what you mean by dynamic footer—can you clarify?
The topic ‘WP 3.9 Validation Failed disables Publish button’ is closed to new replies.
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.