From 214b548485f9313639059e8de1ad08611f734fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 14 Jan 2010 00:56:29 +0100 Subject: Make check boxes accept :multiple as option so they can handle collections (such as HABTM). --- actionpack/lib/action_view/helpers/form_helper.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_view') 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! -- cgit v1.2.3