Inherit collection check boxes from radio

This commit is contained in:
Carlos Antonio da Silva 2012-01-26 17:11:10 -02:00
parent b205528aed
commit c2e1272d8c
3 changed files with 14 additions and 20 deletions

View File

@ -1,6 +1,6 @@
module SimpleForm
module Inputs
class CollectionCheckBoxesInput < CollectionSelectInput
class CollectionCheckBoxesInput < CollectionRadioInput
def input
label_method, value_method = detect_collection_methods
@ -10,12 +10,6 @@ module SimpleForm
)
end
def input_options
options = super
apply_default_collection_options!(options)
options
end
private
# Checkbox components does not use the required html tag.

View File

@ -16,7 +16,19 @@ module SimpleForm
options
end
private
protected
def apply_default_collection_options!(options)
unless options.key?(:item_wrapper_tag)
options[:item_wrapper_tag] = SimpleForm.item_wrapper_tag
end
unless options.key?(:collection_wrapper_tag)
options[:collection_wrapper_tag] = SimpleForm.collection_wrapper_tag
end
options[:collection_wrapper_class] = [
options[:collection_wrapper_class], SimpleForm.collection_wrapper_class
].compact.presence
end
def collection_block_for_nested_boolean_style
return unless nested_boolean_style?

View File

@ -46,18 +46,6 @@ module SimpleForm
!!options[:input_html].try(:[], :multiple)
end
def apply_default_collection_options!(options)
unless options.key?(:item_wrapper_tag)
options[:item_wrapper_tag] = SimpleForm.item_wrapper_tag
end
unless options.key?(:collection_wrapper_tag)
options[:collection_wrapper_tag] = SimpleForm.collection_wrapper_tag
end
options[:collection_wrapper_class] = [
options[:collection_wrapper_class], SimpleForm.collection_wrapper_class
].compact.presence
end
# Detect the right method to find the label and value for a collection.
# If no label or value method are defined, will attempt to find them based
# on default label and value methods that can be configured through