1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

form_for should pass :remote to form_tag through html_options

This commit is contained in:
Stephen St. Martin 2010-01-31 14:42:40 -05:00 committed by Joshua Peek
parent 59e9478f57
commit a3349f845f
2 changed files with 21 additions and 0 deletions

View file

@ -280,6 +280,8 @@ module ActionView
args.unshift object
end
options[:html][:remote] = true if options.delete(:remote)
concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {}))
fields_for(object_name, *(args << options), &proc)
concat('</form>'.html_safe!)

View file

@ -451,6 +451,25 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
def test_form_for_with_remote
form_for(:post, @post, :remote => true, :html => { :id => 'create-post', :method => :put }) do |f|
concat f.text_field(:title)
concat f.text_area(:body)
concat f.check_box(:secret)
end
expected =
"<form action='http://www.example.com' id='create-post' method='post' data-remote='true'>" +
"<div style='margin:0;padding:0;display:inline'><input name='_method' type='hidden' value='put' /></div>" +
"<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)