diff options
author | Alex Chrome <dify.chrome@gmail.com> | 2010-07-28 14:10:39 +0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-09-01 09:59:54 +0200 |
commit | dbf82557e46b748e98a0ab6ed4ab6c823cac4dd2 (patch) | |
tree | ee057b84bb1afe3188d4b90db235d2f46ee61254 /actionpack/lib/action_view/helpers/form_helper.rb | |
parent | a79e985923389863cae0f4a98538096e3723e010 (diff) | |
download | rails-dbf82557e46b748e98a0ab6ed4ab6c823cac4dd2.tar.gz rails-dbf82557e46b748e98a0ab6ed4ab6c823cac4dd2.tar.bz2 rails-dbf82557e46b748e98a0ab6ed4ab6c823cac4dd2.zip |
Added :format option for form_for helper and spec for this [#5226 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 6c3d2cf1b8..94dc25eb85 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -202,6 +202,12 @@ module ActionView # ... # <% end %> # + # You can also set the answer format, like this: + # + # <%= form_for(@post, :format => :json) do |f| %> + # ... + # <% end %> + # # If you have an object that needs to be represented as a different # parameter, like a Client that acts as a Person: # @@ -332,7 +338,9 @@ module ActionView options[:html] ||= {} options[:html].reverse_merge!(html_options) - options[:url] ||= polymorphic_path(object_or_array) + options[:url] ||= options[:format] ? \ + polymorphic_path(object_or_array, :format => options.delete(:format)) : \ + polymorphic_path(object_or_array) end # Creates a scope around a specific model object like form_for, but |