aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/form_tag_helper.rb
diff options
context:
space:
mode:
authorTakayuki Matsubara <takayuki.1229@gmail.com>2013-07-06 01:01:51 +0900
committerTakayuki Matsubara <takayuki.1229@gmail.com>2013-07-07 23:49:38 +0900
commit06388b07791a24e9d3351a74bfdf23809bb1e69b (patch)
treea3252171a03791e8b63f5cb0518a16f19618ce79 /actionview/lib/action_view/helpers/form_tag_helper.rb
parent239126385f75d84e8d62b65879837db0f5ae2f7a (diff)
downloadrails-06388b07791a24e9d3351a74bfdf23809bb1e69b.tar.gz
rails-06388b07791a24e9d3351a74bfdf23809bb1e69b.tar.bz2
rails-06388b07791a24e9d3351a74bfdf23809bb1e69b.zip
Added an `enforce_utf8` hash option for `form_tag` method
Control to output a hidden input tag with name `utf8` without monkey patching Before: form_tag # => '<form>..<input name="utf8" type="hidden" value="&#x2713;" />..</form>' After: form_tag # => '<form>..<input name="utf8" type="hidden" value="&#x2713;" />..</form>' form_tag({}, { :enforce_utf8 => false }) # => '<form>....</form>'
Diffstat (limited to 'actionview/lib/action_view/helpers/form_tag_helper.rb')
-rw-r--r--actionview/lib/action_view/helpers/form_tag_helper.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb
index 3fa7696b83..142c27ace0 100644
--- a/actionview/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/form_tag_helper.rb
@@ -38,6 +38,7 @@ module ActionView
# * A list of parameters to feed to the URL the form will be posted to.
# * <tt>:remote</tt> - If set to true, will allow the Unobtrusive JavaScript drivers to control the
# submit behavior. By default this behavior is an ajax submit.
+ # * <tt>:enforce_utf8</tt> - If set to false, a hidden input with name utf8 is not output.
#
# ==== Examples
# form_tag('/posts')
@@ -719,7 +720,8 @@ module ActionView
method_tag(method) + token_tag(authenticity_token)
end
- tags = utf8_enforcer_tag << method_tag
+ enforce_utf8 = html_options.delete("enforce_utf8") { true }
+ tags = (enforce_utf8 ? utf8_enforcer_tag : ''.html_safe) << method_tag
content_tag(:div, tags, :style => 'margin:0;padding:0;display:inline')
end