grav-plugin-form
grav-plugin-form copied to clipboard
Form Template
Hi Team
I could not find the anyplace where I could declare the form template. I want to change the output html code of the fields. Is there a way I could override the default html structure of the form?
I am also wondering what the template setting is used for. It seems to have no affect at all:
https://learn.getgrav.org/16/forms/forms/form-options#template
Looking at the code, it seems to set a page template, rather than a form template. But it does not work for me.
I'd suggest the following:
templates/forms/form.html.twig should use {% extends "forms/#{ form.template|default('default/form') }.html.twig" %} instead. This would allow us to change the form template (not page template) from the form definition. That would give us more flexibility for the form, without creating whole new page templates or changing the include statements.
if i recall correctly, template form attribute is really intended to be used by ajax calls.
It turns out, that the page loaded after submission will use the specified template. The documentation is missleading here, and specifying the template of the form itself would maybe make more sense. However this would not be backwards compatible, maybe something for 2.0, I dont know?