Class: Primer::Forms::Dsl::RadioButtonInput

Inherits:
Input
  • Object
show all
Defined in:
lib/primer/forms/dsl/radio_button_input.rb

Overview

:nodoc:

Constant Summary

Constants inherited from Input

Input::DEFAULT_SIZE, Input::SIZE_MAPPINGS, Input::SIZE_OPTIONS, Input::SPACE_DELIMITED_ARIA_ATTRIBUTES

Instance Attribute Summary collapse

Attributes inherited from Input

#base_id, #builder, #caption, #form, #form_control, #ids, #input_arguments, #label_arguments, #validation_message

Instance Method Summary collapse

Methods inherited from Input

#add_input_aria, #add_input_classes, #add_input_data, #add_label_classes, #autofocus!, #caption?, #caption_id, #caption_template?, #disabled?, #focusable?, #full_width?, #hidden?, #input?, #invalid?, #merge_input_arguments!, #remove_input_data, #render_caption_template, #required?, #size, #validation_arguments, #validation_error_icon_target, #validation_id, #validation_message_arguments, #validation_messages, #validation_success_icon_target

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(name:, value:, label:, **system_arguments) {|_self| ... } ⇒ RadioButtonInput

Returns a new instance of RadioButtonInput.

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
14
15
16
17
18
# File 'lib/primer/forms/dsl/radio_button_input.rb', line 10

def initialize(name:, value:, label:, **system_arguments)
  @name = name
  @value = value
  @label = label

  super(**system_arguments)

  yield(self) if block_given?
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



8
9
10
# File 'lib/primer/forms/dsl/radio_button_input.rb', line 8

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/primer/forms/dsl/radio_button_input.rb', line 8

def name
  @name
end

#nested_form_argumentsObject (readonly)

Returns the value of attribute nested_form_arguments.



8
9
10
# File 'lib/primer/forms/dsl/radio_button_input.rb', line 8

def nested_form_arguments
  @nested_form_arguments
end

#nested_form_blockObject (readonly)

Returns the value of attribute nested_form_block.



8
9
10
# File 'lib/primer/forms/dsl/radio_button_input.rb', line 8

def nested_form_block
  @nested_form_block
end

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/primer/forms/dsl/radio_button_input.rb', line 8

def value
  @value
end

Instance Method Details

#nested_form(**system_arguments, &block) ⇒ Object



29
30
31
32
# File 'lib/primer/forms/dsl/radio_button_input.rb', line 29

def nested_form(**system_arguments, &block)
  @nested_form_arguments = system_arguments
  @nested_form_block = block
end

#to_componentObject



25
26
27
# File 'lib/primer/forms/dsl/radio_button_input.rb', line 25

def to_component
  RadioButton.new(input: self)
end

#typeObject

:nocov:



35
36
37
# File 'lib/primer/forms/dsl/radio_button_input.rb', line 35

def type
  :radio_button
end

#valid?Boolean

radio buttons cannot be invalid, as both selected and unselected are valid states

Returns:

  • (Boolean)


21
22
23
# File 'lib/primer/forms/dsl/radio_button_input.rb', line 21

def valid?
  true
end