Module: JqueryUiForm::Inputs::BooleanInput

Included in:
FormBuilder
Defined in:
lib/jquery_ui_form/inputs/boolean_input.rb

Instance Method Summary collapse

Instance Method Details

#boolean_input(method, options = {}) ⇒ Object



5
6
7
# File 'lib/jquery_ui_form/inputs/boolean_input.rb', line 5

def boolean_input(method, options = {})
  basic_input_helper(:check_box, :boolean, method, options)   
end

#check_box(method, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jquery_ui_form/inputs/boolean_input.rb', line 9

def check_box(method, options = {})
  checked_value = options.delete(:checked_value) || "1"
  unchecked_value = options.delete(:unchecked_value) || "0"
  unless options[:value].nil?
    value = options.delete(:value)
    if value === true
      options[:checked] = true
    else
      options[:checked] ||= value.to_s == checked_value.to_s
    end
  end
  super(method, options,checked_value, unchecked_value)
end