From 521e964411114a9ff8c95f4129ca7ade8f972d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 13 May 2012 00:47:34 -0300 Subject: Do not add `:include_blank` option if prompt is present --- actionpack/lib/action_view/helpers/tags/base.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_view/helpers/tags/base.rb') diff --git a/actionpack/lib/action_view/helpers/tags/base.rb b/actionpack/lib/action_view/helpers/tags/base.rb index 607954e762..380ebe4b65 100644 --- a/actionpack/lib/action_view/helpers/tags/base.rb +++ b/actionpack/lib/action_view/helpers/tags/base.rb @@ -121,7 +121,7 @@ module ActionView def select_content_tag(option_tags, options, html_options) html_options = html_options.stringify_keys add_default_name_and_id(html_options) - options[:include_blank] ||= true if option_required?(html_options) + options[:include_blank] ||= true unless options[:prompt] || select_not_required?(html_options) select = content_tag("select", add_options(option_tags, options, value(object)), html_options) if html_options["multiple"] && options.fetch(:include_hidden, true) @@ -131,8 +131,8 @@ module ActionView end end - def option_required?(html_options) - html_options["required"] && !html_options["multiple"] && !(html_options["size"].to_i > 1) + def select_not_required?(html_options) + !html_options["required"] || html_options["multiple"] || html_options["size"].to_i > 1 end def add_options(option_tags, options, value = nil) -- cgit v1.2.3