diff options
Diffstat (limited to 'actionview/lib/action_view/helpers/form_tag_helper.rb')
-rw-r--r-- | actionview/lib/action_view/helpers/form_tag_helper.rb | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb index 82f2fd30c7..7bd473507b 100644 --- a/actionview/lib/action_view/helpers/form_tag_helper.rb +++ b/actionview/lib/action_view/helpers/form_tag_helper.rb @@ -1,7 +1,7 @@ -require 'cgi' -require 'action_view/helpers/tag_helper' -require 'active_support/core_ext/string/output_safety' -require 'active_support/core_ext/module/attribute_accessors' +require "cgi" +require "action_view/helpers/tag_helper" +require "active_support/core_ext/string/output_safety" +require "active_support/core_ext/module/attribute_accessors" module ActionView # = Action View Form Tag Helpers @@ -134,11 +134,11 @@ module ActionView if options.include?(:include_blank) include_blank = options.delete(:include_blank) - options_for_blank_options_tag = { value: '' } + options_for_blank_options_tag = { value: "" } if include_blank == true - include_blank = '' - options_for_blank_options_tag[:label] = ' ' + include_blank = "" + options_for_blank_options_tag[:label] = " " end if include_blank @@ -147,7 +147,7 @@ module ActionView end if prompt = options.delete(:prompt) - option_tags = content_tag("option".freeze, prompt, value: '').safe_concat(option_tags) + option_tags = content_tag("option".freeze, prompt, value: "").safe_concat(option_tags) end content_tag "select".freeze, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys) @@ -518,12 +518,12 @@ module ActionView options ||= {} end - options = { 'name' => 'button', 'type' => 'submit' }.merge!(options.stringify_keys) + options = { "name" => "button", "type" => "submit" }.merge!(options.stringify_keys) if block_given? content_tag :button, options, &block else - content_tag :button, content_or_options || 'Button', options + content_tag :button, content_or_options || "Button", options end end @@ -685,7 +685,7 @@ module ActionView text_field_tag(name, value, options.merge(type: :time)) end - # Creates a text field of type "datetime". + # Creates a text field of type "datetime-local". # # === Options # * <tt>:min</tt> - The minimum acceptable value. @@ -693,23 +693,10 @@ module ActionView # * <tt>:step</tt> - The acceptable value granularity. # * Otherwise accepts the same options as text_field_tag. def datetime_field_tag(name, value = nil, options = {}) - ActiveSupport::Deprecation.warn(<<-MESSAGE.squish) - datetime_field_tag is deprecated and will be removed in Rails 5.1. - Use datetime_local_field_tag instead. - MESSAGE - text_field_tag(name, value, options.merge(type: :datetime)) + text_field_tag(name, value, options.merge(type: "datetime-local")) end - # Creates a text field of type "datetime-local". - # - # === Options - # * <tt>:min</tt> - The minimum acceptable value. - # * <tt>:max</tt> - The maximum acceptable value. - # * <tt>:step</tt> - The acceptable value granularity. - # * Otherwise accepts the same options as text_field_tag. - def datetime_local_field_tag(name, value = nil, options = {}) - text_field_tag(name, value, options.merge(type: 'datetime-local')) - end + alias datetime_local_field_tag datetime_field_tag # Creates a text field of type "month". # @@ -870,11 +857,12 @@ module ActionView authenticity_token = html_options.delete("authenticity_token") method = html_options.delete("method").to_s.downcase - method_tag = case method - when 'get' + method_tag = \ + case method + when "get" html_options["method"] = "get" - '' - when 'post', '' + "" + when "post", "" html_options["method"] = "post" token_tag(authenticity_token, form_options: { action: html_options["action"], @@ -886,7 +874,7 @@ module ActionView action: html_options["action"], method: method }) - end + end if html_options.delete("enforce_utf8") { true } utf8_enforcer_tag + method_tag @@ -908,7 +896,7 @@ module ActionView # see http://www.w3.org/TR/html4/types.html#type-name def sanitize_to_id(name) - name.to_s.delete(']').tr('^-a-zA-Z0-9:.', "_") + name.to_s.delete("]").tr("^-a-zA-Z0-9:.", "_") end end end |