Class: Brut::FrontEnd::Forms::RadioButtonGroupInputDefinition
- Inherits:
-
Object
- Object
- Brut::FrontEnd::Forms::RadioButtonGroupInputDefinition
- Includes:
- Brut::Framework::FussyTypeEnforcement
- Defined in:
- lib/brut/front_end/forms/radio_button_group_input_definition.rb
Overview
Defines a radio button group for a form, but not it's runtime state (which includes how many radio buttons would need to be rendered). See RadioButtonInput.
Note that this ultimately defines the contents for a <input type="radio">
tag, so the constraints you can place are only those
supported by the browser. Also note that arrays of radio button groups are not currently supported.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
Instance Method Summary collapse
-
#array? ⇒ Boolean
-
#initialize(name:, required: true, array: false) ⇒ RadioButtonGroupInputDefinition
constructor
Create the input definition.
-
#make_input(value:, index:) ⇒ Object
Create an Input based on this defitition, initializing it with the given value.
Methods included from Brut::Framework::FussyTypeEnforcement
Constructor Details
#initialize(name:, required: true, array: false) ⇒ RadioButtonGroupInputDefinition
Create the input definition
13 14 15 16 17 18 19 20 21 |
# File 'lib/brut/front_end/forms/radio_button_group_input_definition.rb', line 13 def initialize(name:, required: true, array: false) name = name.to_s @name = type!( name , String , "name", required: true) @required = type!( required , [true, false] , "required", required: true) @array = type!( array , [true, false] , "array", required: true) if @array raise Brut::Framework::Errors::NotImplemented, "Arrays of radio button groups are not yet supported" end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/brut/front_end/forms/radio_button_group_input_definition.rb', line 8 def name @name end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
8 9 10 |
# File 'lib/brut/front_end/forms/radio_button_group_input_definition.rb', line 8 def required @required end |
Instance Method Details
#array? ⇒ Boolean
23 |
# File 'lib/brut/front_end/forms/radio_button_group_input_definition.rb', line 23 def array? = @array |
#make_input(value:, index:) ⇒ Object
Create an Input based on this defitition, initializing it with the given value.
26 27 28 |
# File 'lib/brut/front_end/forms/radio_button_group_input_definition.rb', line 26 def make_input(value:, index:) Brut::FrontEnd::Forms::RadioButtonGroupInput.new(input_definition: self, value:, index:) end |