Class: GenericFormFor::Inputs::BooleanInput
- Inherits:
-
Object
- Object
- GenericFormFor::Inputs::BooleanInput
- Includes:
- Base
- Defined in:
- lib/generic_form_for/inputs/boolean_input.rb
Instance Attribute Summary
Attributes included from Base
#builder, #column, #method, #object, #object_name, #options, #template
Instance Method Summary collapse
- #checked? ⇒ Boolean
- #checked_value ⇒ Object
- #input_html(config_options = {}) ⇒ Object
- #input_html_options ⇒ Object
- #required? ⇒ Boolean
- #unchecked_value ⇒ Object
Methods included from Base
#autofocus?, #default_input_options, #form_builder_options, #initialize, #input_html_class, #input_options, #merge_html_options, #to_html, #wrap_in
Methods included from GenericFormFor::Inputs::Base::ErrorMessage
#error_html, #error_html_options, #errors, #errors?, #render_error?
Methods included from GenericFormFor::Inputs::Base::Label
#label_html, #label_html_options, #label_text, #render_label?, #requirement_text, #translated_label
Methods included from GenericFormFor::Inputs::Base::Validations
#decimals, #limit, #limits_from_validations, #maximal_number, #minimal_number, #required_from_validations?
Methods included from GenericFormFor::Inputs::Base::Hint
#hint_html, #hint_html_options, #hint_text, #render_hint?
Methods included from GenericFormFor::I18n
#translate, #translate_action, #translate_hint, #translate_label, #translate_legend, #translate_placeholder
Instance Method Details
#checked? ⇒ Boolean
22 23 24 25 26 27 28 |
# File 'lib/generic_form_for/inputs/boolean_input.rb', line 22 def checked? if .key?(:value) return checked_value.to_s == [:value].to_s end return false unless object.respond_to?(method) checked_value.to_s == object.send(method).to_s end |
#checked_value ⇒ Object
18 19 20 |
# File 'lib/generic_form_for/inputs/boolean_input.rb', line 18 def checked_value [:checked_value] || '1' end |
#input_html(config_options = {}) ⇒ Object
10 11 12 |
# File 'lib/generic_form_for/inputs/boolean_input.rb', line 10 def input_html(={}) template.concat builder.check_box(method, (,), checked_value, unchecked_value) end |
#input_html_options ⇒ Object
6 7 8 |
# File 'lib/generic_form_for/inputs/boolean_input.rb', line 6 def {:checked => checked?}.merge(super).except(*[:checked_value, :unchecked_value, :value]) end |
#required? ⇒ Boolean
30 31 32 |
# File 'lib/generic_form_for/inputs/boolean_input.rb', line 30 def required? false end |
#unchecked_value ⇒ Object
14 15 16 |
# File 'lib/generic_form_for/inputs/boolean_input.rb', line 14 def unchecked_value [:unchecked_value] || '0' end |