Remix.run Logo
singpolyma3 an hour ago

You can have button actions today by wrapping the button in a form tag. The article even shows this. The implication seems to be somehow that this is no good because what if you're already in a form tag? The answer is to move the two actions which aren't actually related to the form outside of the form tag and give them their own unique form parents.

marklar423 35 minutes ago | parent | next [-]

I had the same thought at first, but the example in the article convinced me. It's something I ran into when I did webdev.

Form tags usually contain other elements - textboxes, checkboxes, etc. The url and method are specified on the form tag and not the button, so if you want a second submit button that goes to a different URL or use a different method, you need to duplicate all the other inputs in a separate form tag with your button.

All of this can be done with scripting, but the point of this proposal is to make that unnecessary.

minitech 32 minutes ago | parent [-]

The `formaction` and `formmethod` attributes already exist. https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...

marklar423 6 minutes ago | parent | next [-]

I stand corrected, thanks for pointing it out. I suppose then I'm back to not seeing the utility of the proposal over form tags.

wky 17 minutes ago | parent | prev [-]

Additionally, the proposal of button actions is for the opposite purpose, when you want to avoid sending the form data when the button is pressed.

crooked-v 36 minutes ago | parent | prev [-]

And don't forget about the `form` attribute to associate a button with any arbitrary form element by ID.