grav-plugin-form
grav-plugin-form copied to clipboard
Invalid form name used
I have a page that adds two forms:
- via twig include:
{% include "forms/form.html.twig" with { form: forms('testform') } %}
- via plugin aka
$this->grav['page']->addForms()
Now if I submit the first with invalid data (for example no checkboxes checked, when they are required) and then try to submit the second form with valid data, the error from form 1 is still shown. This does not happen in the other direction or when using multiple forms via twig include.
The issue is, that form.name
is using the name of the first form, after submitting. The hidden field for the second form then contains invalid data. It turns out, that normally the second form gets added via onTwigVariables()
in form.php
, but the if (!isset($twig->twig_vars['form']))
check returns false, as the error message is shown in there.
I have no clue how to fix that, as the logic is super complex.