Checkboxes with collection now support only one checked checkbox, when select with multiple: 'multiple' support multiple selected items.
I suggest change method in Formular::Element::Modules::Checkable
def is_checked?
!options[:checked].nil? || reader_value == options[:value]
end
to something like this
def is_checked?
return !options[:checked].nil? || reader_value == options[:value] unless reader_value.is_a?(Array)
reader_value.map(&:to_s).include?(options[:value].to_s) # TODO Perf improvement here - do we need the map?
end
aka in Select Element
def item_is_selected(option_val, current_val, multiple)
return option_val == current_val.to_s unless multiple && current_val.is_a?(Array)
current_val.map(&:to_s).include?(option_val) # TODO Perf improvement here - do we need the map?
end
Why?
It's unusual behavior in form builder with checkboxes. Array mean multiple choises and multiple checked elements.
Checkboxes with collection now support only one checked checkbox, when select with
multiple: 'multiple'support multiple selected items.I suggest change method in
Formular::Element::Modules::Checkableto something like this
aka in Select Element
Why?
It's unusual behavior in form builder with checkboxes. Array mean multiple choises and multiple checked elements.