Support

Account

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);
                }
            }
        }
    }