1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00

Merge pull request #1211 from strangeworks/master

Can't set collection for configured custom value input
This commit is contained in:
Ulisses Almeida 2015-03-31 20:44:39 -03:00
commit 39280bf82c
2 changed files with 12 additions and 1 deletions

View file

@ -508,8 +508,8 @@ module SimpleForm
# collection is given.
def default_input_type(attribute_name, column, options)
return options[:as].to_sym if options[:as]
return :select if options[:collection]
custom_type = find_custom_type(attribute_name.to_s) and return custom_type
return :select if options[:collection]
input_type = column.try(:type)
case input_type

View file

@ -46,6 +46,17 @@ class FormBuilderTest < ActionView::TestCase
end
end
test 'builder does not override custom input mappings for custom collection' do
swap SimpleForm, input_mappings: { /gender$/ => :check_boxes } do
with_concat_form_for @user do |f|
f.input :gender, collection: [:male, :female]
end
assert_no_select 'select option', 'Male'
assert_select 'input[type=checkbox][value=male]'
end
end
test 'builder allows to skip input_type class' do
swap SimpleForm, generate_additional_classes_for: [:label, :wrapper] do
with_form_for @user, :post_count