Hi,
I’ve been trying to create an ACF Block that renders a Blade template following this discussion as a guide, using the renderCallback approach because I’m aware that acf_register_block_type() is deprecated. However, I’m running into an issue where no parameters are being passed into my callback function. My codebase looks something like this:
resources/views/blocks/new-block/block.json:
...
"acf": {
"mode": "auto",
"renderCallback": "\\App\\blade_render_callback",
"postTypes": ["page"],
"blockVersion": 2
},
...
resources/views/blocks/new-block/new-block.blade.php:
<p>Hello world</p>
app/controllers/App.php:
public function blade_render_callback($block, string $content = '', bool $is_preview = false, int $post_id = 0, array $wp_block = [], array $context = [])
{
echo \Roots\view('blocks/new-block')->render();
}
This throws an error where the blade_render_callback() expects at least 1 argument to be passed, but receives 0. If I change my controller function to provide a default value of an empty array for $block, I get a different error in vendor/roots/acorn/src/Roots/helpers.php due to a call to an undefined function app() on line 73.
Any advice on how to fix this issue would be greatly appreciated.
Thanks! ![]()