Hi,
This is probably not the best place to post this question but I wanted
to know whether using multiple form tags in the same view page should
be avoided or it is not a problem? I have heard few people saying that
one must avoid using multiple forms on the same page but I never got a
convincing explanation for the same. I need some thoughts on this.
Thanks,
Chirantan
On Mon, Dec 8, 2008 at 4:07 AM, Chirantan [email protected]
wrote:
I have heard few people saying that
one must avoid using multiple forms on the same page but I never got a
convincing explanation for the same.
I’ve never heard that, and can’t imagine why anyone would think it a
problem. I’ve certainly had projects that required multiple forms per
page.
FWIW,
Hassan S. ------------------------ [email protected]
I agree with Hassan. If you want to give your pages multiple
functionality you have to be able to use multiple forms. Just look at
Amazon, for example. After you have chosen a book/other and it’s in
your cart you have a form to check out but they also offer selecting
more items. Are both things one and the same or are they run by the
same form? I hardly think so.
Pepe
On Dec 8, 11:17 am, “Hassan S.” [email protected]
POST data is not structured, so while you can use multiple forms on
the same page, there could also be namespace conflicts. The resulting
query string (in case of a conflict) could be really bizarre and prone
to subtle bugs. Not a problem when it’s you writing the code or when
the page is stupid-simple. Problem if you are doing complicated stuff
and others might inherit the code.
If you want to see how Amazon implemented their form, Firebug is your
friend.
I’m not trying to convince, just offer a possible explanation
On Tue, Dec 9, 2008 at 4:24 PM, s.ross [email protected] wrote:
POST data is not structured, so while you can use multiple forms on
the same page, there could also be namespace conflicts. The resulting
query string (in case of a conflict) could be really bizarre and prone
to subtle bugs.
Yes, you have to be careful with multiple forms on the page to not
have duplicate element IDs and whatnot, particularly if you’re using
JavaScript. However, you can only /submit/ one form at a time, so
there should be no problem on the back end.
And I’m not sure what that second sentence means, since POST data
isn’t delivered as a “query string”.
Can you clarify?
–
Hassan S. ------------------------ [email protected]
On Tue, Dec 9, 2008 at 5:18 PM, s.ross [email protected] wrote:
Well, POST data is actually delivered as-if a hidden query string. So,
for a GET request, you have an HTTP QUERY_STRING and for a POST
request you have a RAW_POST_DATA. Both are functionally equivalent
Mmm. Well, they both deliver data, so I suppose you could say
that. Angels, pins, tomato, tomahto, whatever
Look, it can and does work, and there’s no reason to believe it will
stop any time soon. But why use multiple tags when one will do?
Are they posting to different actions?
Of course. Why else would you do it?
Do they expect to know the contents of fields in the other form?
Not in any example I’ve developed (or seen).
Should the user expect to know
the behavior of hitting enter when in one form or the other (can they
really tell they are in a different form)?
If they don’t understand what’s going on, someone’s done a crappy
job of UX design, but that applies to so many things
–
Hassan S. ------------------------ [email protected]
Well, POST data is actually delivered as-if a hidden query string. So,
for a GET request, you have an HTTP QUERY_STRING and for a POST
request you have a RAW_POST_DATA. Both are functionally equivalent and
neither are scoped.
Look, it can and does work, and there’s no reason to believe it will
stop any time soon. But why use multiple tags when one will do?
Are they posting to different actions? Do they expect to know the
contents of fields in the other form? Should the user expect to know
the behavior of hitting enter when in one form or the other (can they
really tell they are in a different form)?
I’m not a fan, but if there’s a clear argument why this is a
simplifying practice, I’m all ears.