Sha256: 8c834298c3bd843a96d13ea6392a432d108f940151c3e9c3eda5f45961e010b0
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
module Formulaic module Inputs class CheckboxInput < ArrayInput def fill if has_check_boxes? check_boxes true else false end end private def has_check_boxes? contains_all_options?(checkbox_labels) end def check_boxes value.each { |checkbox| check checkbox } end def checkbox_labels all(checkbox_labels_selector) end def checkbox_name_selector "input[type='checkbox'][name='#{label.model_name}[#{label.attribute}][]']" end def checkbox_name_selector_for_association "input[type='checkbox'][name='#{label.model_name}[#{label.attribute.to_s.singularize}_ids][]']" end 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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
formulaic-0.4.1 | lib/formulaic/inputs/checkbox_input.rb |
formulaic-0.4.0 | lib/formulaic/inputs/checkbox_input.rb |
formulaic-0.3.0 | lib/formulaic/inputs/checkbox_input.rb |