class Formulaic::Inputs::CheckboxInput

Public Instance Methods

fill() click to toggle source
# File lib/formulaic/inputs/checkbox_input.rb, line 4
def fill
  if has_check_boxes?
    check_boxes
    true
  else
    false
  end
end

Private Instance Methods

check_boxes() click to toggle source
# File lib/formulaic/inputs/checkbox_input.rb, line 19
def check_boxes
  value.each { |checkbox| check checkbox }
end
checkbox_labels() click to toggle source
# File lib/formulaic/inputs/checkbox_input.rb, line 23
def checkbox_labels
  all(checkbox_labels_selector)
end
checkbox_labels_selector() click to toggle source
# File lib/formulaic/inputs/checkbox_input.rb, line 35
def checkbox_labels_selector
  [
    "#{checkbox_name_selector} ~ label",
    "label:has(#{checkbox_name_selector})",
    "#{checkbox_name_selector_for_association} ~ label",
    "label:has(#{checkbox_name_selector_for_association})",
  ].join(",")
end
checkbox_name_selector() click to toggle source
# File lib/formulaic/inputs/checkbox_input.rb, line 27
def checkbox_name_selector
  "input[type='checkbox'][name='#{label.model_name}[#{label.attribute}][]']"
end
checkbox_name_selector_for_association() click to toggle source
# File lib/formulaic/inputs/checkbox_input.rb, line 31
def checkbox_name_selector_for_association
  "input[type='checkbox'][name='#{label.model_name}[#{label.attribute.to_s.singularize}_ids][]']"
end
has_check_boxes?() click to toggle source
# File lib/formulaic/inputs/checkbox_input.rb, line 15
def has_check_boxes?
  contains_all_options?(checkbox_labels)
end