Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form in modular pages documentation is outdated #867

Open
NicoHood opened this issue Dec 5, 2020 · 4 comments
Open

Form in modular pages documentation is outdated #867

NicoHood opened this issue Dec 5, 2020 · 4 comments

Comments

@NicoHood
Copy link
Contributor

NicoHood commented Dec 5, 2020

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.

@NicoHood
Copy link
Contributor Author

NicoHood commented Dec 9, 2020

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

@mahagr
Copy link
Member

mahagr commented Jan 15, 2021

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.

@NicoHood
Copy link
Contributor Author

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?

@mahagr
Copy link
Member

mahagr commented Jan 18, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants