diff options
author | Olek Janiszewski <olek.janiszewski@gmail.com> | 2013-03-08 18:07:09 +0100 |
---|---|---|
committer | Olek Janiszewski <olek.janiszewski@gmail.com> | 2013-03-08 19:01:32 +0100 |
commit | 8e05a6f6380c6ddbef5a0620b30d19dbca7f2f15 (patch) | |
tree | 91d3089df0d9679a0a17c0308a83e27545fe20bb /actionpack/lib/action_view/helpers | |
parent | dd1d309fa9c158607a35fee2c18b477728811ad8 (diff) | |
download | rails-8e05a6f6380c6ddbef5a0620b30d19dbca7f2f15.tar.gz rails-8e05a6f6380c6ddbef5a0620b30d19dbca7f2f15.tar.bz2 rails-8e05a6f6380c6ddbef5a0620b30d19dbca7f2f15.zip |
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][]")
# => <select name="post[category][][]" ...>
After:
select(:category, [], {}, multiple: true, name: "post[category][]")
# => <select name="post[category][]" ...>
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/tags/base.rb | 2 |
1 files changed, 1 insertions, 1 deletions
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 |