grav-plugin-form icon indicating copy to clipboard operation
grav-plugin-form copied to clipboard

Form Template

Open navjinder opened this issue 4 years ago • 3 comments

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?

navjinder avatar Dec 17 '19 18:12 navjinder

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.

NicoHood avatar Jan 09 '21 16:01 NicoHood

if i recall correctly, template form attribute is really intended to be used by ajax calls.

rhukster avatar Jan 11 '21 19:01 rhukster

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?

NicoHood avatar Jan 11 '21 23:01 NicoHood