Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #553 from gmanley/inline_label_config_tweak

If inline_label opt is true use default label text
  • Loading branch information...
commit 51fe90c2ba778c9f65caaed264fc08a441835467 2 parents d43bbe9 + 53e2323
@carlosantoniodasilva carlosantoniodasilva authored
View
3  lib/simple_form/inputs/boolean_input.rb
@@ -3,9 +3,10 @@ module Inputs
class BooleanInput < Base
def input
if nested_boolean_style?
+ inline_label = options[:inline_label] == true ? label_text : options[:inline_label]
build_hidden_field_for_checkbox +
template.label_tag(nil, :class => "checkbox") {
- build_check_box_without_hidden_field + options[:inline_label]
+ build_check_box_without_hidden_field + inline_label
}
else
build_check_box
View
7 test/inputs/boolean_input_test.rb
@@ -36,6 +36,13 @@ class BooleanInputTest < ActionView::TestCase
end
end
+ test 'input boolean with nested style creates an inline label using the default label text when inline_label option set to true' do
+ swap SimpleForm, :boolean_style => :nested do
+ with_input_for @user, :active, :boolean, :label => false, :inline_label => true
+ assert_select 'label.checkbox', :text => 'Active'
+ end
+ end
+
test 'input boolean with nested generates a manual hidden field for checkbox outside the label, to recreate Rails functionality with valid html5' do
swap SimpleForm, :boolean_style => :nested do
with_input_for @user, :active, :boolean
Please sign in to comment.
Something went wrong with that request. Please try again.