Sha256: fa2bcc1d14742495e4f3387598a7342a9312dfb11258191266733d229bccb900
Contents?: true
Size: 1.06 KB
Versions: 9
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Primer module Forms # :nodoc: class CheckBox < BaseComponent delegate :builder, :form, to: :@input def initialize(input:) @input = input @input.add_label_classes("FormControl-label") @input.add_input_classes("FormControl-checkbox") return unless @input.scheme == :array @input.input_arguments[:multiple] = true @input.label_arguments[:value] = checked_value end def nested_form_arguments return @nested_form_arguments if defined?(@nested_form_arguments) @nested_form_arguments = { **@input.nested_form_arguments } @nested_form_arguments[:class] = class_names( @nested_form_arguments[:class], @nested_form_arguments.delete(:classes), "ml-4" ) @nested_form_arguments end private def checked_value @input.value || "1" end def unchecked_value return if @input.scheme == :array @input.unchecked_value || "0" end end end end
Version data entries
9 entries across 9 versions & 1 rubygems