I am curious as to what is the best practice here and why.
I am working with a new team that urges me to nest all forms into standard pages rather than linking to the form asset itself. It has been suggested that we do this with asset listings too.
I have never done this in the past because of the caching warnings, however the forms do seem to be work just fine. What do you think?
It is against best practice to nest forms in like that, because of caching mainly. If the form action URL is still to the Custom Form itslef, then it should be fine, but you can easily break it again by moving the custom form under an area that doesn’t have a URL.
If you are using something like Squiz Edge or Varnish, you could also use ESI tags to next the forms into the page, which would get around the caching problem.
Another option is to use a content template to pick the right form, then use an ajax or iframe based approach where you load the form in dynamically and post to it via the iframe or ajax.
We try to stay away from nesting forms in but when creating campaign pages that require everything on that one page, we tend to use get/post with ajax like Bart suggested, which works fine with custom forms rather than nesting the asset in itself and having cache problems down the line.
What are you trying to achieve in nesting the form?
When I have needed to do something like this for layout purposes, I have just applied a Paint Layout to the form that then allows me to do a lot more custom formatting inside of the Paint Layout.
Good points! Thanks everyone.
All I can gather is they are nesting them to keep the back end folders organised.
All forms live in their own ‘forms’ folder separate to the content. They are then nested in the content where required.
I’m not the biggest fan of this method because any additional CSS/JS has to live on the nested page, and not in form itself, which kind of complicates things.
I I have always been told not to nest forms so I have always followed that advice. I nested a form shown here (cached) then in the Advanced Settings > form submission URL > I selected the page’s own URL (not cached).
This worked fine for me but it’s not something I would get in the habit of doing
So you want to nest your forms, but there are caching issues so:
- You could add a special exemption in Cache Manager for every “Page that contains a form” but that’s a drag
- You could set your forms to submit to their own URL but that’s messy and also a drag
Solution - Nest your forms in other forms!
Custom Form assets automatically don’t get cached, so instead of nesting your actual Form in a Standard Page, create a second (fieldless) Form, override the Page Contents bodycopy, and nest your real form in your fake form! You don’t need to manually exempt it in Cache Manager, and you don’t need to set the form to submit to a different URL.
p.s. Do not actually do this
Yeah don’t nest forms. If the system gives you a warning - believe it. eeek
With Edit+ you can just use the form page and customise the contents easy.