class SimpleForm::Inputs::BooleanInput
def build_check_box(unchecked_value='0')
which won't generate the hidden checkbox. This is the default functionality
reuse the method for nested boolean style, but with no unchecked value,
Build a checkbox tag using default unchecked value. This allows us to
def build_check_box(unchecked_value='0') @builder.check_box(attribute_name, input_html_options, '1', unchecked_value) end
def build_check_box_without_hidden_field
Build a checkbox without generating the hidden field. See
def build_check_box_without_hidden_field build_check_box(nil) end
def build_hidden_field_for_checkbox
we need the hidden field to be *outside* the label (otherwise it
functionality with hidden + checkbox, but under a nested context, where
Create a hidden field for the current checkbox, so we can simulate Rails
def build_hidden_field_for_checkbox @builder.hidden_field(attribute_name, :value => '0', :id => nil, :disabled => input_html_options[:disabled]) end
def input
def input if nested_boolean_style? build_hidden_field_for_checkbox + template.label_tag(nil, :class => "checkbox") { build_check_box_without_hidden_field } else build_check_box end end
def label_input
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
def required_by_default?
it makes no sense marking them as required. The only exception is
Booleans are not required by default because in most of the cases
def required_by_default? false end