In the changlog…
“Developers who wish to modify the default advisory text can do so with the new acf/blocks/no_fields_assigned_message filter which offers 2 parameters: the message to be displayed and the name of the block it will be displayed on.”
The documentation hasn’t kept up, does anyone have a code snippet for this filter please?
For anyone who passes this way;
add_filter ('acf/blocks/no_fields_assigned_message', 'no_fields_message', 10, 2);
function no_fields_message($message, $block_name) {
if ($block_name === "acf/my-block") {
$message = "Nothing to see here, please move along";
}
return $message;
}
Here are two additions in case you a) want to have a unified message for all ACF blocks without ACF fields or b) want the message to disappear completely.
// ACF Blocks: Alter message for all ACF blocks that contain no ACF fields
function no_fields_message($message) {
$message = __('No fields for this block', 'projectname');
return $message;
}
add_filter ('acf/blocks/no_fields_assigned_message', 'no_fields_message', 10, 2);
// ACF Blocks: Remove no-fields message for all ACB blocks without ACF fields
add_filter( 'acf/blocks/no_fields_assigned_message', '__return_empty_string' );