Class: Flowbite::Input::Select

Inherits:
Field
  • Object
show all
Defined in:
app/components/flowbite/input/select.rb

Overview

The ‘Select` component renders a select input field for use in forms.

flowbite.com/docs/forms/select/

Wraps ‘ActionView::Helpers::FormOptionsHelper#select`: api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select

Constant Summary collapse

SIZES =
{
  sm: ["p-2", "text-xs"],
  default: ["p-2.5", "text-sm"],
  lg: ["px-4", "py-3", "text-base"]
}.freeze

Constants inherited from Field

Field::STATES

Instance Attribute Summary

Attributes inherited from Field

#options, #size, #style

Instance Method Summary collapse

Methods inherited from Field

classes, #classes, sizes, styles

Constructor Details

#initialize(form:, attribute:, collection: [], disabled: false, options: {}, size: :default) ⇒ Select

Returns a new instance of Select.



17
18
19
20
# File 'app/components/flowbite/input/select.rb', line 17

def initialize(form:, attribute:, collection: [], disabled: false, options: {}, size: :default)
  super(form: form, attribute: attribute, disabled: disabled, options: options, size: size)
  @collection = collection
end

Instance Method Details

#callObject

Returns the HTML to use for the actual input field element.



23
24
25
26
27
28
29
30
31
# File 'app/components/flowbite/input/select.rb', line 23

def call
  @form.send(
    input_field_type,
    @attribute,
    @collection,
    {},
    html_options
  )
end

#input_field_typeObject

Returns the name of the method used to generate HTML for the input field



34
35
36
# File 'app/components/flowbite/input/select.rb', line 34

def input_field_type
  :select
end