From dce6ade4cdc2833b53bd600ef10f9bce83c7102d Mon Sep 17 00:00:00 2001 From: Andrew Kaspick Date: Tue, 30 Sep 2008 14:15:36 -0500 Subject: Ensure select_tag#name attribute uses [] when :multiple is true. [#1146 state:resolved] Signed-off-by: Pratik Naik --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_view/helpers/form_tag_helper.rb') diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 208bf91dd4..7492348c50 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -62,7 +62,7 @@ module ActionView # # # # select_tag "colors", "", :multiple => true - # # => # # # # select_tag "locations", "" @@ -70,14 +70,15 @@ module ActionView # # # # select_tag "access", "", :multiple => true, :class => 'form_input' - # # => # # # # select_tag "destination", "", :disabled => true # # => def select_tag(name, option_tags = nil, options = {}) - content_tag :select, option_tags, { "name" => name, "id" => name }.update(options.stringify_keys) + html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name + content_tag :select, option_tags, { "name" => html_name, "id" => name }.update(options.stringify_keys) end # Creates a standard text field; use these text fields to input smaller chunks of text like a username -- cgit v1.2.3