Home › Forums › Gutenberg › Required fields in Gutenberg editor › Reply To: Required fields in Gutenberg editor
I am not sure why this is still an issue and can only apologise for not requiring (pardon the pun) this feature earlier.
The issue is due to the Validation not accepting anything but directly assigned fields, it ignores acf_blocks_{UNIQUE_ID}.
So… Until ACF Dev updates the core code, add the below snippet to functions.php as a workaround. DEMO
add_action( 'acf/validate_save_post', '_validate_save_post', 5 );
function _validate_save_post() {
// bail early if no $_POST
$acf = false;
foreach($_POST as $key => $value) {
if (strpos($key, 'acf') === 0) {
if (! empty( $_POST[$key] ) ) {
acf_validate_values( $_POST[$key], $key);
}
}
}
}
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.