Skip to content

Commit

Permalink
Fix boolean nested style bootstrap integration
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosantoniodasilva committed Jan 30, 2012
1 parent 8d9e67b commit 12850f8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/simple_form/inputs/boolean_input.rb
Expand Up @@ -2,7 +2,11 @@ module SimpleForm
module Inputs
class BooleanInput < Base
def input
build_check_box
if nested_boolean_style?
template.label_tag(nil, :class => "checkbox") { build_check_box(nil) }
else
build_check_box
end
end

def label_input
Expand Down
21 changes: 20 additions & 1 deletion test/inputs/boolean_input_test.rb
Expand Up @@ -49,7 +49,26 @@ class BooleanInputTest < ActionView::TestCase
swap SimpleForm, :boolean_style => :nested do
with_input_for @user, :active, :boolean, :label => false
assert_select 'input.boolean'
assert_no_select 'label'
assert_no_select 'label.boolean'
end
end

test 'input boolean works using :input only in wrapper config (no label_input)' do
swap_wrapper do
with_input_for @user, :active, :boolean

assert_select 'label.boolean + input[type=hidden] + input.boolean'
assert_no_select 'label.checkbox'
end
end

test 'input boolean with nested style works using :input only in wrapper config (no label_input), adding the extra "checkbox" label wrapper' do
swap_wrapper do
swap SimpleForm, :boolean_style => :nested do
with_input_for @user, :active, :boolean

assert_select 'label.boolean + label.checkbox > input.boolean'
end
end
end
end

0 comments on commit 12850f8

Please sign in to comment.