class Primer::Forms::Dsl::CheckBoxInput
:nodoc:
def initialize(name:, label:, value: nil, unchecked_value: nil, scheme: DEFAULT_SCHEME, **system_arguments)
def initialize(name:, label:, value: nil, unchecked_value: nil, scheme: DEFAULT_SCHEME, **system_arguments) raise ArgumentError, "Check box scheme must be one of #{SCHEMES.join(', ')}" unless SCHEMES.include?(scheme) raise ArgumentError, "Check box needs an explicit value if scheme is array" if scheme == :array && value.nil? @name = name @label = label @value = value @unchecked_value = unchecked_value @scheme = scheme super(**system_arguments) yield(self) if block_given? end
def nested_form(**system_arguments, &block)
def nested_form(**system_arguments, &block) @nested_form_arguments = system_arguments @nested_form_block = block end
def supports_validation?
def supports_validation? false end
def to_component
def to_component CheckBox.new(input: self) end
def type
def type :check_box end
def valid?
check boxes cannot be invalid, as both checked and unchecked are valid states
def valid? true end
def values_disambiguate_template_names?
def values_disambiguate_template_names? # Check boxes submitted as an array all have the same name, so we return true here # to ensure different caption templates can be attached to individual check box inputs. @scheme == :array end