Skip to content

Commit

Permalink
Override only the component rendering method.
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Dec 27, 2012
1 parent dc212a5 commit c8f586c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: git://github.com/rails/rails.git
revision: ceedec7edcadbad824f58e84bc2c1eddbe8539ce
revision: 42d9b480121e15a15cddd2015a1e60a0f9e0f953
branch: master
specs:
actionpack (4.0.0.beta)
Expand Down
30 changes: 2 additions & 28 deletions lib/simple_form/action_view_extensions/builder.rb
Expand Up @@ -71,17 +71,7 @@ class CollectionRadioButtons < ActionView::Helpers::Tags::CollectionRadioButtons
include CollectionExtensions

def render
rendered_collection = render_collection do |item, value, text, default_html_options|
builder = instantiate_builder(RadioButtonBuilder, item, value, text, default_html_options)

if block_given?
yield builder
else
render_component(builder)
end
end

wrap_rendered_collection(rendered_collection, @options)
wrap_rendered_collection(super, @options)
end

private
Expand All @@ -95,22 +85,7 @@ class CollectionCheckBoxes < ActionView::Helpers::Tags::CollectionCheckBoxes
include CollectionExtensions

def render
rendered_collection = render_collection do |item, value, text, default_html_options|
default_html_options[:multiple] = true
builder = instantiate_builder(CheckBoxBuilder, item, value, text, default_html_options)

if block_given?
yield builder
else
render_component(builder)
end
end

# Append a hidden field to make sure something will be sent back to the
# server if all check boxes are unchecked.
hidden = @template_object.hidden_field_tag("#{tag_name}[]", "", :id => nil)

wrap_rendered_collection(rendered_collection + hidden, @options)
wrap_rendered_collection(super, @options)
end

private
Expand Down Expand Up @@ -227,7 +202,6 @@ def collection_radio_buttons(method, collection, value_method, text_method, opti
# * item_wrapper_class => the CSS class to use for item_wrapper_tag
#
# * a block => to generate the label + check box or any other component.
#
def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
SimpleForm::Tags::CollectionCheckBoxes.new(@object_name, method, @template, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options)).render(&block)
end
Expand Down

0 comments on commit c8f586c

Please sign in to comment.