Display form on website

I’ve created a form in the panel with the block plugin from @Microman but can’t figure out how to output the blocks on my page. I’m new to using blocks but thought something like this should work:

 <?= $page->myform()->toBlocks() ?>

but this gives me a Block error: "Undefined variable $block" in block type: "form"

Can someone maybe point me in the right direction?

This was a common issue. Please update the Plugin.

Thanks for your quick respons. I’ve updated to version 2.0.3 and I’m on Kirby 3.7.5 but still get the above error with the same code.

When I’m in kirby-form-blocks/snippets/blocks/form.php the problem is in the first line where it says <?php $form = $block; ?> removing that resolves the issue but I’m sure it’s there for a reason an breaks some functionality? Please let me know!

As you see in the discussion of the issue i’ts not definitively clear which method really works.

I’m sorry I don’t really understand what you mean… Can I remove <?php $form = $block; ?> without any consequences since everything seems to work properly if I do?

You can remove that cause $form is already set (in some cases). That <?php $form = $block; ?> overrides the $form. In case it’s not available.
Ahmet from the kirby core team took care of that. Both work now.

1 Like