mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Experimental boolean select option
This commit is contained in:
parent
4320fb614f
commit
72b331e047
2 changed files with 13 additions and 1 deletions
|
@ -30,6 +30,9 @@ module SimpleForm
|
|||
result << radio_button(@attribute, value, html_options) <<
|
||||
label("#{@attribute}_#{value}", text, :class => default_css_classes)
|
||||
end
|
||||
elsif @input_type == :select
|
||||
return select(@attribute, boolean_collection,
|
||||
@options[:options], html_options)
|
||||
end
|
||||
|
||||
mapping = MAPPINGS[@input_type]
|
||||
|
|
|
@ -135,7 +135,7 @@ class InputTest < ActionView::TestCase
|
|||
assert_select 'form input.string#user_born_at'
|
||||
end
|
||||
|
||||
test 'input should allow boolean fields as radio buttons' do
|
||||
test 'input should allow boolean attributes as radio buttons' do
|
||||
simple_form_for @user do |f|
|
||||
concat f.input :active, :as => :radio
|
||||
end
|
||||
|
@ -151,6 +151,15 @@ class InputTest < ActionView::TestCase
|
|||
assert_select 'form label.radio[for=user_active_false]', 'No'
|
||||
end
|
||||
|
||||
test 'input should allow boolean attributes as a select with options' do
|
||||
simple_form_for @user do |f|
|
||||
concat f.input :active, :as => :select
|
||||
end
|
||||
assert_select 'form select.select#user_active'
|
||||
assert_select 'form select option[value=true]', 'Yes'
|
||||
assert_select 'form select option[value=false]', 'No'
|
||||
end
|
||||
|
||||
test 'input should generate a password field for password attributes' do
|
||||
simple_form_for @user do |f|
|
||||
concat f.input :password
|
||||
|
|
Loading…
Reference in a new issue