Class: Brut::FrontEnd::Forms::SelectInputDefinition
- Inherits:
-
Object
- Object
- Brut::FrontEnd::Forms::SelectInputDefinition
- Includes:
- Brut::Framework::FussyTypeEnforcement
- Defined in:
- lib/brut/front_end/forms/select_input_definition.rb
Overview
Defines a <select>
for a form, but not it's current runtime state. SelectInput is used to understand the current state or value of a select.
Note that a select input definition is defining an HTML <select>
, not a generic attribute. Thus, the only constraints you can place on
an input are those that the browser supports. If your form needs server side validation, you can accomplish that in a lot of ways,
such as implementing a BackEnd::Validators::FormValidator, or calling
Brut::FrontEnd::Form#server_side_constraint_violation directly.
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) ⇒ SelectInputDefinition
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) ⇒ SelectInputDefinition
Create the input definition
14 15 16 17 18 19 |
# File 'lib/brut/front_end/forms/select_input_definition.rb', line 14 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) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/brut/front_end/forms/select_input_definition.rb', line 9 def name @name end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
9 10 11 |
# File 'lib/brut/front_end/forms/select_input_definition.rb', line 9 def required @required end |
Instance Method Details
#array? ⇒ Boolean
21 |
# File 'lib/brut/front_end/forms/select_input_definition.rb', line 21 def array? = @array |
#make_input(value:, index:) ⇒ Object
Create an Input based on this defitition, initializing it with the given value.
24 25 26 |
# File 'lib/brut/front_end/forms/select_input_definition.rb', line 24 def make_input(value:, index:) Brut::FrontEnd::Forms::SelectInput.new(input_definition: self, value:, index:) end |