From 3384ee24adb1ac38fdadbb755523ffb9f6bda9cc Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Sat, 10 Mar 2012 23:30:39 +1300 Subject: Fixes #5324 by removing default size options from input:text and default cols and rows options from textarea. --- actionpack/lib/action_view/helpers/form_helper.rb | 30 +++++++++++----------- actionpack/lib/action_view/helpers/tags/base.rb | 2 -- .../lib/action_view/helpers/tags/text_area.rb | 4 +-- .../lib/action_view/helpers/tags/text_field.rb | 3 +-- 4 files changed, 17 insertions(+), 22 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 7492ef56c6..0970ad96d1 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -45,10 +45,10 @@ module ActionView # # # : - #
+ #
# # : - #
+ #
# # # @@ -76,10 +76,10 @@ module ActionView # # # : - #
+ #
# # : - #
+ #
# # # @@ -757,7 +757,7 @@ module ActionView # # # # text_area(:application, :notes, :cols => 40, :rows => 15, :class => 'app_input') - # # => # @@ -860,20 +860,20 @@ module ActionView # ==== Examples # # search_field(:user, :name) - # # => + # # => # search_field(:user, :name, :autosave => false) - # # => + # # => # search_field(:user, :name, :results => 3) - # # => + # # => # # Assume request.host returns "www.example.com" # search_field(:user, :name, :autosave => true) - # # => + # # => # search_field(:user, :name, :onsearch => true) - # # => + # # => # search_field(:user, :name, :autosave => false, :onsearch => true) - # # => + # # => # search_field(:user, :name, :autosave => true, :onsearch => true) - # # => + # # => # def search_field(object_name, method, options = {}) Tags::SearchField.new(object_name, method, self, options).render @@ -882,7 +882,7 @@ module ActionView # Returns a text_field of type "tel". # # telephone_field("user", "phone") - # # => + # # => # def telephone_field(object_name, method, options = {}) Tags::TelField.new(object_name, method, self, options).render @@ -910,7 +910,7 @@ module ActionView # Returns a text_field of type "url". # # url_field("user", "homepage") - # # => + # # => # def url_field(object_name, method, options = {}) Tags::UrlField.new(object_name, method, self, options).render @@ -919,7 +919,7 @@ module ActionView # Returns a text_field of type "email". # # email_field("user", "address") - # # => + # # => # def email_field(object_name, method, options = {}) Tags::EmailField.new(object_name, method, self, options).render diff --git a/actionpack/lib/action_view/helpers/tags/base.rb b/actionpack/lib/action_view/helpers/tags/base.rb index 22c16de057..14323a3891 100644 --- a/actionpack/lib/action_view/helpers/tags/base.rb +++ b/actionpack/lib/action_view/helpers/tags/base.rb @@ -5,8 +5,6 @@ module ActionView include Helpers::ActiveModelInstanceTag, Helpers::TagHelper, Helpers::FormTagHelper include FormOptionsHelper - DEFAULT_FIELD_OPTIONS = { "size" => 30 } - attr_reader :object def initialize(object_name, method_name, template_object, options = {}) diff --git a/actionpack/lib/action_view/helpers/tags/text_area.rb b/actionpack/lib/action_view/helpers/tags/text_area.rb index 461a049fc2..2e48850d5c 100644 --- a/actionpack/lib/action_view/helpers/tags/text_area.rb +++ b/actionpack/lib/action_view/helpers/tags/text_area.rb @@ -2,10 +2,8 @@ module ActionView module Helpers module Tags class TextArea < Base #:nodoc: - DEFAULT_TEXT_AREA_OPTIONS = { "cols" => 40, "rows" => 20 } - def render - options = DEFAULT_TEXT_AREA_OPTIONS.merge(@options.stringify_keys) + options = @options.stringify_keys add_default_name_and_id(options) if size = options.delete("size") diff --git a/actionpack/lib/action_view/helpers/tags/text_field.rb b/actionpack/lib/action_view/helpers/tags/text_field.rb index ce5182d20f..024a1a8af2 100644 --- a/actionpack/lib/action_view/helpers/tags/text_field.rb +++ b/actionpack/lib/action_view/helpers/tags/text_field.rb @@ -4,8 +4,7 @@ module ActionView class TextField < Base #:nodoc: def render options = @options.stringify_keys - options["size"] = options["maxlength"] || DEFAULT_FIELD_OPTIONS["size"] unless options.key?("size") - options = DEFAULT_FIELD_OPTIONS.merge(options) + options["size"] = options["maxlength"] unless options.key?("size") options["type"] ||= field_type options["value"] = options.fetch("value"){ value_before_type_cast(object) } unless field_type == "file" options["value"] &&= ERB::Util.html_escape(options["value"]) -- cgit v1.2.3 From 8b5198a41704b333f56204e185fe0e8d832b2509 Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Mon, 12 Mar 2012 10:33:47 +1300 Subject: Fix unintended removal of 'cols' from a text_area example. --- actionpack/lib/action_view/helpers/form_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 0970ad96d1..835111eb95 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -757,7 +757,7 @@ module ActionView # # # # text_area(:application, :notes, :cols => 40, :rows => 15, :class => 'app_input') - # # => # -- cgit v1.2.3