From 42d9b480121e15a15cddd2015a1e60a0f9e0f953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 26 Dec 2012 23:30:38 -0300 Subject: Extract the component rendering of collection_radio_buttons and collection_check_boxes to a private method. It will make easier to extend. Example: class CollectionRadioButtons < ActionView::Helpers::Tags::CollectionRadioButtons include CollectionExtensions def render wrap_rendered_collection(super, @options) end private def render_component(builder) builder.radio_button + builder.label(:class => "collection_radio_buttons") end end --- actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb | 8 +++++++- .../lib/action_view/helpers/tags/collection_radio_buttons.rb | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb index 45f0bc3d7b..d27df45b5a 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb @@ -21,7 +21,7 @@ module ActionView if block_given? yield builder else - builder.check_box + builder.label + render_component(builder) end end @@ -31,6 +31,12 @@ module ActionView rendered_collection + hidden end + + private + + def render_component(builder) + builder.check_box + builder.label + end end end end diff --git a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb b/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb index ba2035f074..81f2ecb2b3 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb @@ -20,10 +20,16 @@ module ActionView if block_given? yield builder else - builder.radio_button + builder.label + render_component(builder) end end end + + private + + def render_component(builder) + builder.radio_button + builder.label + end end end end -- cgit v1.2.3