Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11415 (closed enhancement: fixed)

Opened 8 months ago

Last modified 8 months ago

[PATCH] Add confirm option to submit_tag

Reported by: miloops Assigned to: core
Priority: normal Milestone: 2.x
Component: ActionPack Version: edge
Severity: minor Keywords: submit_tag confirm tiny
Cc:

Description

When submitting a form i found sometimes very helpful, when updating something critical, that the user must confirm the form in order to get it submitted.

Up to now the way to do this is: <%= submit_tag('Save changes', :onclick => "return confirm('Are you sure?')") %>

With this enhancement you get the same for something sweeter: <%= submit_tag('Save changes', :confirm => "Are you sure?") %>

Goodbye javascript, and api more consistent with link_to.

Test and docs included.

Attachments

add_submit_tag_confirm.diff (3.0 kB) - added by miloops on 03/24/08 21:10:08.

Change History

03/24/08 21:10:08 changed by miloops

  • attachment add_submit_tag_confirm.diff added.

03/24/08 21:24:43 changed by david

  • status changed from new to closed.
  • resolution set to fixed.

(In [9087]) Added :confirm option to submit_tag (closes #11415) [miloops]

03/24/08 21:35:25 changed by jerome

  • status changed from closed to reopened.
  • resolution deleted.
  • severity changed from normal to minor.

I don't understand this commit since it already worked with rails 1.2 and probably earlier as I use it on production for more than a year !!!

03/24/08 22:04:10 changed by miloops

  • status changed from reopened to closed.
  • resolution set to fixed.

Can you confirm that in a more descriptive way?

If you comment out the lines added to submit_tag the new test fails:

<"<input name=\"commit\" type=\"submit\" value=\"Save\" onclick=\"return confirm('Are you sure?');\" />"> expected to be == to <"<input name=\"commit\" confirm=\"Are you sure?\" type=\"submit\" value=\"Save\" />">.

This is because the feature was *not* implemented and the option was parsed as a html option. Also double checked in applications running agains't trunk and it doesn't work.

03/25/08 00:16:59 changed by jerome

My apologies. I did overwrite that method helper about 2 years ago so I forgot it wasn't bundled with rails. I should have submit this patch earlier :P

Sorry again. Regards