Changeset 4374
- Timestamp:
- 05/28/06 23:39:37 (2 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/form_tag_helper.rb (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/prototype_helper.rb (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/url_helper.rb (modified) (2 diffs)
- trunk/actionpack/test/template/prototype_helper_test.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r4371 r4374 1 1 *SVN* 2 3 * Added :method handling for other verbs to remote_form_tag and remote_form_for [DHH] 2 4 3 5 * Expanded :method option in FormHelper#form_tag to allow for verbs other than GET and POST by automatically creating a hidden form field named _method, which will simulate the other verbs over post [DHH] trunk/actionpack/lib/action_view/helpers/form_tag_helper.rb
r4371 r4374 21 21 html_options = options.stringify_keys 22 22 html_options["enctype"] = "multipart/form-data" if html_options.delete("multipart") 23 html_options["action"] = url_for(url_for_options, *parameters_for_url)24 23 html_options["action"] = url_for(url_for_options, *parameters_for_url) 24 25 25 method_tag = "" 26 26 trunk/actionpack/lib/action_view/helpers/prototype_helper.rb
r4268 r4374 165 165 options[:html] ||= {} 166 166 options[:html][:onsubmit] = "#{remote_function(options)}; return false;" 167 options[:html][:action] = options[:html][:action] || url_for(options[:url]) 168 options[:html][:method] = options[:html][:method] || "post" 169 170 tag("form", options[:html], true) 167 168 form_tag(options[:html].delete(:action) || url_for(options[:url]), options[:html]) 171 169 end 172 170 trunk/actionpack/lib/action_view/helpers/url_helper.rb
r4370 r4374 25 25 escape = true 26 26 end 27 27 28 url = @controller.send(:url_for, options, *parameters_for_method_reference) 28 29 escape ? html_escape(url) : url … … 58 59 tag_options = nil 59 60 end 61 60 62 url = options.is_a?(String) ? options : self.url_for(options, *parameters_for_method_reference) 61 63 "<a href=\"#{url}\"#{tag_options}>#{name || url}</a>" trunk/actionpack/test/template/prototype_helper_test.rb
r4014 r4374 9 9 include ActionView::Helpers::TagHelper 10 10 include ActionView::Helpers::TextHelper 11 include ActionView::Helpers::FormTagHelper 11 12 include ActionView::Helpers::FormHelper 12 13 include ActionView::Helpers::CaptureHelper … … 15 16 @controller = Class.new do 16 17 def url_for(options, *parameters_for_method_reference) 17 url = "http://www.example.com/" 18 url << options[:action].to_s if options and options[:action] 19 url << "?a=#{options[:a]}" if options && options[:a] 20 url << "&b=#{options[:b]}" if options && options[:a] && options[:b] 21 url 18 if options.is_a?(String) 19 options 20 else 21 url = "http://www.example.com/" 22 url << options[:action].to_s if options and options[:action] 23 url << "?a=#{options[:a]}" if options && options[:a] 24 url << "&b=#{options[:b]}" if options && options[:a] && options[:b] 25 url 26 end 22 27 end 23 28 end.new … … 61 66 assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer',failure:'glass_of_water'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">), 62 67 form_remote_tag(:update => { :success => 'glass_of_beer', :failure => "glass_of_water" }, :url => { :action => :fast }) 68 end 69 70 def test_form_remote_tag_with_method 71 assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"><input name='_method' type='hidden' value='put' />), 72 form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, :html => { :method => :put }) 63 73 end 64 74