From 8e05a6f6380c6ddbef5a0620b30d19dbca7f2f15 Mon Sep 17 00:00:00 2001 From: Olek Janiszewski Date: Fri, 8 Mar 2013 18:07:09 +0100 Subject: Fix incorrectly appended square brackets to a multiple select box If an explicit name has been given and it already ends with "[]" Before: select(:category, [], {}, multiple: true, name: "post[category][]") # => --- actionpack/lib/action_view/helpers/tags/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/helpers/tags/base.rb b/actionpack/lib/action_view/helpers/tags/base.rb index 3d597079c4..aef1572290 100644 --- a/actionpack/lib/action_view/helpers/tags/base.rb +++ b/actionpack/lib/action_view/helpers/tags/base.rb @@ -84,7 +84,7 @@ module ActionView options["id"] = options.fetch("id"){ tag_id } end - options["name"] += "[]" if options["multiple"] + options["name"] += "[]" if options["multiple"] && !options["name"].ends_with?("[]") options["id"] = [options.delete('namespace'), options["id"]].compact.join("_").presence end -- cgit v1.2.3