Sha256: d7f0e1a7ad6b49d368afe108cd4c18b7c684658134168acf21992e736da0a502
Contents?: true
Size: 1.2 KB
Versions: 22
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true module Phlexi module Form module Components class CollectionCheckboxes < Base include Concerns::HandlesInput include Concerns::HandlesArrayInput include Concerns::AcceptsChoices def view_template div(**attributes.slice(:id, :class)) do field.repeated(choices.values) do |builder| render builder.hidden_field_tag if builder.index == 0 field = builder.field( label: choices[builder.key], # We set the attributes here so they are applied to all input components even if the user decides to use a block input_attributes: { checked_value: builder.key, include_hidden: false, checked: selected?(builder.key) } ) if block_given? yield field else render field.checkbox_tag render field.label_tag end end end end protected def build_attributes super attributes[:multiple] = true end end end end end
Version data entries
22 entries across 22 versions & 1 rubygems