Class: SimpleFormWithClientValidation::Inputs::BooleanInput

Inherits:
Base
  • Object
show all
Defined in:
lib/simple_form_with_client_validation/inputs/boolean_input.rb

Instance Attribute Summary

Attributes inherited from Base

#attribute_name, #column, #html_classes, #input_html_classes, #input_html_options, #input_type, #options, #reflection

Instance Method Summary collapse

Methods inherited from Base

disable, enable, #initialize, #input_options

Methods included from SimpleFormWithClientValidation::I18nCache

#get_i18n_cache, #i18n_cache, #reset_i18n_cache

Methods included from Components::Readonly

#readonly

Methods included from Components::Placeholders

#placeholder, #placeholder_text

Methods included from Components::Pattern

#pattern

Methods included from Components::MinMax

#min_max

Methods included from Components::Minlength

#minlength

Methods included from Components::Maxlength

#maxlength

Methods included from Components::HTML5

#has_required?, #html5, #html5?, #initialize

Methods included from Components::Hints

#has_hint?, #hint

Methods included from Components::Errors

#error, #has_errors?

Methods included from Helpers::Validators

#has_validators?

Constructor Details

This class inherits a constructor from SimpleFormWithClientValidation::Inputs::Base

Instance Method Details

#inputObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/simple_form_with_client_validation/inputs/boolean_input.rb', line 4

def input
  if nested_boolean_style?
    build_hidden_field_for_checkbox +
      template.label_tag(nil, :class => "checkbox") {
        build_check_box_without_hidden_field + options[:inline_label]
      }
  else
    build_check_box
  end
end

#label_inputObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/simple_form_with_client_validation/inputs/boolean_input.rb', line 15

def label_input
  if options[:label] == false
    input
  elsif nested_boolean_style?
    html_options = label_html_options.dup
    html_options[:class].push(:checkbox)

    build_hidden_field_for_checkbox +
      @builder.label(label_target, html_options) {
        build_check_box_without_hidden_field + label_text
      }
  else
    input + label
  end
end