From 106c988c10c29332343d8de5719a8b045d093753 Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Sun, 27 Oct 2013 18:14:16 +0300 Subject: add include_hidden option to collection_check_boxes helper --- .../lib/action_view/helpers/tags/collection_check_boxes.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'actionview/lib/action_view/helpers') diff --git a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb index 9b77ebeb1b..8b28e4fc33 100644 --- a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb +++ b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb @@ -27,10 +27,14 @@ module ActionView # Append a hidden field to make sure something will be sent back to the # server if all check boxes are unchecked. - hidden_name = @html_options[:name] || "#{tag_name}[]" - hidden = @template_object.hidden_field_tag(hidden_name, "", :id => nil) + if @options.fetch(:include_hidden, true) + hidden_name = @html_options[:name] || "#{tag_name}[]" + hidden = @template_object.hidden_field_tag(hidden_name, "", :id => nil) - rendered_collection + hidden + rendered_collection + hidden + else + rendered_collection + end end private -- cgit v1.2.3