can use blank collection with grouped_collection input, closes #430
This commit is contained in:
parent
f67bdbb122
commit
beb5158d1f
|
@ -19,7 +19,7 @@ module SimpleForm
|
|||
|
||||
# Sample collection
|
||||
def collection
|
||||
@collection ||= grouped_collection.first.try(:send, group_method)
|
||||
@collection ||= grouped_collection.first.try(:send, group_method) || []
|
||||
end
|
||||
|
||||
def group_method
|
||||
|
|
|
@ -20,6 +20,15 @@ class GroupedCollectionSelectInputTest < ActionView::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test 'grouped collection accepts empty array collection form' do
|
||||
with_input_for @user, :tag_ids, :grouped_select,
|
||||
:collection => [],
|
||||
:group_method => :last
|
||||
|
||||
assert_select 'select.grouped_select#user_tag_ids'
|
||||
end
|
||||
|
||||
|
||||
test 'grouped collection accepts proc as collection' do
|
||||
with_input_for @user, :tag_ids, :grouped_select,
|
||||
:collection => Proc.new { [['Authors', ['Jose', 'Carlos']], ['General', ['Bob', 'John']]] },
|
||||
|
|
Loading…
Reference in New Issue