Class: Yattho::Forms::Dsl::SelectListInput

Inherits:
Input
  • Object
show all
Defined in:
lib/yattho/forms/dsl/select_list_input.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Option

Constant Summary collapse

SELECT_ARGUMENTS =
%i[multiple include_blank prompt].freeze

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

#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?, #full_width?, #hidden?, #input?, #invalid?, #merge_input_arguments!, #need_validation_element?, #remove_input_data, #render_caption_template, #required?, #size, #valid?, #validation_arguments, #validation_id, #validation_message_arguments, #validation_messages

Methods included from ClassNameHelper

#class_names

Constructor Details

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

Returns a new instance of SelectListInput.

Yields:

  • (_self)

Yield Parameters:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/yattho/forms/dsl/select_list_input.rb', line 23

def initialize(name:, label:, **system_arguments)
  @name = name
  @label = label
  @options = []

  @select_arguments = {}.tap do |select_args|
    SELECT_ARGUMENTS.each do |select_arg|
      select_args[select_arg] = system_arguments.delete(select_arg)
    end
  end

  super(**system_arguments)

  yield(self) if block_given?
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



21
22
23
# File 'lib/yattho/forms/dsl/select_list_input.rb', line 21

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/yattho/forms/dsl/select_list_input.rb', line 21

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/yattho/forms/dsl/select_list_input.rb', line 21

def options
  @options
end

#select_argumentsObject (readonly)

Returns the value of attribute select_arguments.



21
22
23
# File 'lib/yattho/forms/dsl/select_list_input.rb', line 21

def select_arguments
  @select_arguments
end

Instance Method Details

#focusable?Boolean

:nocov:

Returns:

  • (Boolean)


54
55
56
# File 'lib/yattho/forms/dsl/select_list_input.rb', line 54

def focusable?
  true
end

#option(**system_arguments) ⇒ Object



39
40
41
# File 'lib/yattho/forms/dsl/select_list_input.rb', line 39

def option(**system_arguments)
  @options << Option.new(**system_arguments)
end

#to_componentObject



43
44
45
# File 'lib/yattho/forms/dsl/select_list_input.rb', line 43

def to_component
  SelectList.new(input: self)
end

#typeObject

:nocov:



48
49
50
# File 'lib/yattho/forms/dsl/select_list_input.rb', line 48

def type
  :select_list
end