getgrav / grav-learn

Grav Learn (exhaustive grav documentation)

Home Page:http://learn.getgrav.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Form in modular pages documentation is outdated

NicoHood opened this issue · comments

https://learn.getgrav.org/16/forms/forms/how-to-forms-in-modular-pages

From my testing it seems that the following changes are not true for the current forms plugin 4.2:

  • templates/form.html.twig should be renamed to templates/modular/form.html.twig
  • templates/formdata.html.twig should be removed
  • An example for templates/modular/form.html.twig is currently missing in antimatter or other themes (I can provide an example for quark, if you wish)
  • The form can (and in my opinion should) be placed in the modular page, not the "full page". This is the location where the form is used, so it should be defined there.
  • This also means the cache must be disabled in the modular page
  • action can be left empty, it will just work. I used #anchor to scroll to the modular page however. It might be a useful hint.

If you wish, I can add a modular form for quark theme, similar to the text template but with a form instead of an image.

This documentation might be also affected: https://learn.getgrav.org/16/forms/forms#modular-forms

Please be free to fix the documentation.

In the mean time there's a reason why the form is in the "parent" page. That is basically needed to make the URL correct, otherwise submitting the form fails (blueprints are needed to validate the form). We used to have forms in modular, but none of them were working without a lot of trickery by the person who wrote the form. And that generally meant writing some code as well.

The current solution is nowhere perfect, though, but at least makes the forms to work (yes, action used to be mandatory). Also before moving the forms into the parent form submission randomly failed because of cache timeouts loosing the forms.

Cache must be disabled in any page having a form (including parent page if you have modular form). That is a limitation of current implementation.

Hm, I did not need to disable the cache, but I added the form loading inside the twig template, not the markdown file.

Having the form in the parent makes sense. It seems to still work on my case, even with redirect to page.url. Maybe all those bugs are fixed by now?

Oh yeah, you cannot really add form loading to Markdown as there's really no way to find out that form needs to be loaded. I think there's a way to get some forms to work like that, but.. It's complicated.