diff options
author | Vasiliy Ermolovich <younash@gmail.com> | 2012-03-13 19:59:04 +0300 |
---|---|---|
committer | Vasiliy Ermolovich <younash@gmail.com> | 2012-03-13 20:00:50 +0300 |
commit | 54a75e1a0f1c2369a9a4b2872c2213d32a8bc117 (patch) | |
tree | 24857b38b2a5f57347822b655e2ffdb26a6cacdf /actionpack/lib/action_view/helpers | |
parent | 21b69b233bda5870274c84ef8178c9ad9a47c390 (diff) | |
download | rails-54a75e1a0f1c2369a9a4b2872c2213d32a8bc117.tar.gz rails-54a75e1a0f1c2369a9a4b2872c2213d32a8bc117.tar.bz2 rails-54a75e1a0f1c2369a9a4b2872c2213d32a8bc117.zip |
add 'include_hidden' option to select tag, closes #5402
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_options_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/tags/base.rb | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index 5be3da9b94..d61c2bbee2 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -153,6 +153,8 @@ module ActionView # form, and parameters extraction gets the last occurrence of any repeated # key in the query string, that works for ordinary forms. # + # In case if you don't want the helper to generate this hidden field you can specify <tt>:include_blank => false</tt> option. + # def select(object, method, choices, options = {}, html_options = {}) Tags::Select.new(object, method, self, choices, options, html_options).render end diff --git a/actionpack/lib/action_view/helpers/tags/base.rb b/actionpack/lib/action_view/helpers/tags/base.rb index 14323a3891..7c2f12d8e7 100644 --- a/actionpack/lib/action_view/helpers/tags/base.rb +++ b/actionpack/lib/action_view/helpers/tags/base.rb @@ -122,7 +122,8 @@ module ActionView html_options = html_options.stringify_keys add_default_name_and_id(html_options) select = content_tag("select", add_options(option_tags, options, value(object)), html_options) - if html_options["multiple"] + + if html_options["multiple"] && options.fetch(:include_hidden) { true } tag("input", :disabled => html_options["disabled"], :name => html_options["name"], :type => "hidden", :value => "") + select else select |