ruby on rails - Active Admin checkboxes not selected when edit model -
i'm using custom collection display checkboxes schedule. saves, when try edit returns me unchecked. why?
f.inputs for: :schedule, name: 'employee schedule' |sf| sf.input :sunday, as: :check_boxes, collection: available_hours, method: :to_s sf.input :monday, as: :check_boxes, collection: available_hours, method: :to_s sf.input :tuesday, as: :check_boxes, collection: available_hours, method: :to_s sf.input :wednesday, as: :check_boxes, collection: available_hours, method: :to_s sf.input :thursday, as: :check_boxes, collection: available_hours, method: :to_s sf.input :friday, as: :check_boxes, collection: available_hours, method: :to_s sf.input :saturday, as: :check_boxes, collection: available_hours, method: :to_s end def available_hours (0..23).map { |h| ["#{h}h às #{h.next}h", h] } end helper_method :available_hours
i found solution question
my collection remains unaltered
def available_hours array(0..23) end
and form have :member_label
parameter receiving proc change after collection gathered
member_label: proc.new { |h| "#{h}h às #{h.next}h" }
after modifications:
sf.input :sunday, as: :check_boxes, collection: available_hours, member_label: proc.new { |h| "#{h}h às #{h.next}h" } , method: :to_s
and on...
Comments
Post a Comment