提交 a1864314 编写于 作者: D David Genord II 提交者: Jeremy Kemper

form_for without :html and with :remote should not error

[#4902 state:committed]
Signed-off-by: NJeremy Kemper <jeremy@bitsweat.net>
上级 9d3eeb90
......@@ -302,7 +302,7 @@ def form_for(record_or_name_or_array, *args, &proc)
args.unshift object
end
options[:html][:remote] = true if options.delete(:remote)
(options[:html] ||= {})[:remote] = true if options.delete(:remote)
output = form_tag(options.delete(:url) || {}, options.delete(:html) || {})
output << fields_for(object_name, *(args << options), &proc)
......
......@@ -644,6 +644,26 @@ def test_form_for_with_remote
assert_dom_equal expected, output_buffer
end
def test_form_for_with_remote_without_html
assert_deprecated do
form_for(:post, @post, :remote => true) do |f|
concat f.text_field(:title)
concat f.text_area(:body)
concat f.check_box(:secret)
end
end
expected =
"<form action='http://www.example.com' method='post' data-remote='true'>" +
"<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
"<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
"<input name='post[secret]' type='hidden' value='0' />" +
"<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
"</form>"
assert_dom_equal expected, output_buffer
end
def test_form_for_without_object
form_for(:post, :html => { :id => 'create-post' }) do |f|
concat f.text_field(:title)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册