diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-14 00:56:29 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-14 01:07:03 +0100 |
commit | 214b548485f9313639059e8de1ad08611f734fe2 (patch) | |
tree | fb6701f290abf58c31f12b4d2e0a9a094dc3a995 /actionpack/lib | |
parent | d50bf47b008ae4c1a84ccc44e8fc7633bfffa650 (diff) | |
download | rails-214b548485f9313639059e8de1ad08611f734fe2.tar.gz rails-214b548485f9313639059e8de1ad08611f734fe2.tar.bz2 rails-214b548485f9313639059e8de1ad08611f734fe2.zip |
Make check boxes accept :multiple as option so they can handle collections (such as HABTM).
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index ef1c51d4e7..fe060921ff 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -842,7 +842,12 @@ module ActionView checked = self.class.check_box_checked?(value(object), checked_value) end options["checked"] = "checked" if checked - add_default_name_and_id(options) + if options["multiple"] + add_default_name_and_id_for_value(checked_value, options) + options.delete("multiple") + else + add_default_name_and_id(options) + end hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => options['disabled'] && checked ? checked_value : unchecked_value) checkbox = tag("input", options) (hidden + checkbox).html_safe! |