mirror of https://github.com/rails/rails
data-remote needs to be on the form and not the submit when using button_to :remote=>true
This commit is contained in:
parent
a9e89e82b6
commit
e1618b9ac3
|
@ -286,6 +286,8 @@ module ActionView
|
||||||
|
|
||||||
form_method = method.to_s == 'get' ? 'get' : 'post'
|
form_method = method.to_s == 'get' ? 'get' : 'post'
|
||||||
|
|
||||||
|
remote = html_options.delete('remote')
|
||||||
|
|
||||||
request_token_tag = ''
|
request_token_tag = ''
|
||||||
if form_method == 'post' && protect_against_forgery?
|
if form_method == 'post' && protect_against_forgery?
|
||||||
request_token_tag = tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token)
|
request_token_tag = tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token)
|
||||||
|
@ -298,7 +300,7 @@ module ActionView
|
||||||
|
|
||||||
html_options.merge!("type" => "submit", "value" => name)
|
html_options.merge!("type" => "submit", "value" => name)
|
||||||
|
|
||||||
("<form method=\"#{form_method}\" action=\"#{escape_once url}\" class=\"button-to\"><div>" +
|
("<form method=\"#{form_method}\" action=\"#{escape_once url}\" #{"data-remote=\"true\"" if remote} class=\"button-to\"><div>" +
|
||||||
method_tag + tag("input", html_options) + request_token_tag + "</div></form>").html_safe!
|
method_tag + tag("input", html_options) + request_token_tag + "</div></form>").html_safe!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,13 @@ class UrlHelperTest < ActionView::TestCase
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_button_to_with_remote_and_javascript_confirm
|
||||||
|
assert_dom_equal(
|
||||||
|
"<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\" data-remote=\"true\"><div><input data-confirm=\"Are you sure?\" type=\"submit\" value=\"Hello\" /></div></form>",
|
||||||
|
button_to("Hello", "http://www.example.com", :remote => true, :confirm => "Are you sure?")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def test_button_to_enabled_disabled
|
def test_button_to_enabled_disabled
|
||||||
assert_dom_equal(
|
assert_dom_equal(
|
||||||
"<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>",
|
"<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>",
|
||||||
|
|
Loading…
Reference in New Issue