Nesting forms in standard pages?


(John) #1

Hey friends
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?


(Bart Banda) #2

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.


(Tim Trodd) #3

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.


(Nic Hubbard) #4

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.


(John) #5

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.


(Nick Papadatos) #6

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
N


(John gill) #7

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


#8

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.