Simple question about submit

It's such a simple question ... and I can't find an answer.

When I put up a form and I have a submit button ... cleary when the user clicks on it a uri is generated. What is that uri?

In other words ... what method in which controller is generally called when the user hits to submit button?

Ralph Shnelvar wrote:

It's such a simple question ... and I can't find an answer.

Because it's a basic HTML question, not a Rails one.

When I put up a form and I have a submit button ... cleary when the user clicks on it a uri is generated. What is that uri?

Whatever the <form> tag's action is.

In other words ... what method in which controller is generally called when the user hits to submit button?

Whatever method your routes map that URL to.

Marnen Laibow-Koser wrote:

Whatever the <form> tag's action is.

Also, if no action is specified via the form tag, the form is submitted to the current url.

So if 'thing/edit/1' contained:

<form>   <input type="submit" /> </form>

The form would be submitted back to 'thing/edit/1'

Rob and Marnen:

Thank you!

I am now curious why the designers of HTML put the "place to go" on the form tag rather than on the <input type="submit" /> tag.

Ralph

Ralph Shnelvar wrote:

Rob and Marnen:

Thank you!

I am now curious why the designers of HTML put the "place to go" on the form tag rather than on the <input type="submit" /> tag.

My guess: the idea is that the action is a property of the *form*, not the submit button. But take this up on an HTML forum if you want better answers. We're out of Rails territory here.

Rob Nichols wrote:

Marnen Laibow-Koser wrote:

Whatever the <form> tag's action is.

Also, if no action is specified via the form tag, the form is submitted to the current url.

So if 'thing/edit/1' contained:

<form>   <input type="submit" /> </form>

The form would be submitted back to 'thing/edit/1'

No. <form> without an action is invalid HTML, so its behavior is undefined. An action must always be specified.

Best,

How do you know that the next version of FF will do that? Have you tested all available browsers? What about Chinese versions? If you develop a website that does not generate valid html then next week an update to IE may break the website and your clients/users will not be happy.

Colin

Yet you make the mistake yourself by saying "browsers will" instead of "browsers *may*".

What action the user agent performs if an 'action' parameter of a form is anything other than an http(s):// url is undefined... so they're free to do what they want. http://www.w3.org/TR/html401/interact/forms.html#h-17.3

If *you* want to be *sure* a form submits how you want, you *must* include an action parameter. If you don't care what your form does, then you *should* do whatever you prefer :slight_smile:

On this and other forums I sometimes get the suggestion "Try it".

I have made the comment in forums to the effect that "Just because it works does not mean that it is defined to work".

Ralph Shnelvar wrote:

On this and other forums I sometimes get the suggestion "Try it".

I have made the comment in forums to the effect that "Just because it works does not mean that it is defined to work".

That sounds like something I hear at work from time to time...

"It is not known not to work"...