Inherit collection check boxes from radio
This commit is contained in:
parent
b205528aed
commit
c2e1272d8c
|
@ -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.
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue