mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Use both configured and given collection_wrapper_class
This commit is contained in:
parent
082cbe28a6
commit
853e4ef7c4
2 changed files with 20 additions and 1 deletions
|
@ -139,7 +139,8 @@ module SimpleForm
|
|||
|
||||
def render_collection(attribute, collection, value_method, text_method, options={}, html_options={}) #:nodoc:
|
||||
collection_wrapper_tag = options.has_key?(:collection_wrapper_tag) ? options[:collection_wrapper_tag] : SimpleForm.collection_wrapper_tag
|
||||
collection_wrapper_class = options.has_key?(:collection_wrapper_class) ? options[:collection_wrapper_class] : SimpleForm.collection_wrapper_class
|
||||
collection_wrapper_class = [SimpleForm.collection_wrapper_class, options[:collection_wrapper_class]].compact
|
||||
collection_wrapper_class = nil if collection_wrapper_class.empty?
|
||||
item_wrapper_tag = options.has_key?(:item_wrapper_tag) ? options[:item_wrapper_tag] : SimpleForm.item_wrapper_tag
|
||||
|
||||
rendered_collection = collection.map do |item|
|
||||
|
|
|
@ -138,6 +138,15 @@ class BuilderTest < ActionView::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test 'collection radio uses both configured and given classes for collection wrapper tag' do
|
||||
swap SimpleForm, :collection_wrapper_tag => :ul, :collection_wrapper_class => :'inputs-list' do
|
||||
with_collection_radio @user, :active, [true, false], :to_s, :to_s, :collection_wrapper_class => :'items-list'
|
||||
|
||||
assert_select 'form ul.inputs-list.items-list input[type=radio][value=true]#user_active_true'
|
||||
assert_select 'form ul.inputs-list.items-list input[type=radio][value=false]#user_active_false'
|
||||
end
|
||||
end
|
||||
|
||||
test 'collection radio uses no class for collection wrapper tag by default' do
|
||||
swap SimpleForm, :collection_wrapper_tag => :ul do
|
||||
with_collection_radio @user, :active, [true, false], :to_s, :to_s
|
||||
|
@ -335,6 +344,15 @@ class BuilderTest < ActionView::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test 'collection check box uses both configured and given classes for collection wrapper tag' do
|
||||
swap SimpleForm, :collection_wrapper_tag => :ul, :collection_wrapper_class => :'inputs-list' do
|
||||
with_collection_check_boxes @user, :active, [true, false], :to_s, :to_s, :collection_wrapper_class => :'items-list'
|
||||
|
||||
assert_select 'form ul.inputs-list.items-list input[type=checkbox][value=true]#user_active_true'
|
||||
assert_select 'form ul.inputs-list.items-list input[type=checkbox][value=false]#user_active_false'
|
||||
end
|
||||
end
|
||||
|
||||
test 'collection check box uses no class for collection wrapper tag by default' do
|
||||
swap SimpleForm, :collection_wrapper_tag => :ul do
|
||||
with_collection_check_boxes @user, :active, [true, false], :to_s, :to_s
|
||||
|
|
Loading…
Reference in a new issue