class

Kemal::Form::SelectField

Inherits Kemal::Form::Field / Reference / Object

A select form field.

class SelectForm < Kemal::Form
  field colors : Kemal::Form::SelectField,
                 options: [
                   Kemal::Form::SelectField::Option.new("blue"),
                   Kemal::Form::SelectField::Option.new("green"),
                   Kemal::Form::SelectField::Option.new("red"),
                   Kemal::Form::SelectField::Option.new("yellow")
                 ]
end

will render

<select id="colors" name="colors">
  <option value="blue">blue</option>
  <option value="green">green</option>
  <option value="red">red</option>
  <option value="yellow">yellow</option>
</select>

Constructors

new(id, name, value, required, label, attrs = {} of String => String, validators = [] of Kemal::FormValidator::Validator, options : Array(Kemal::Form::SelectField::Option) = [] of Option)

Initializes a new SelectField.

Source

Instance methods

options

Returns the field's options.

Source
to_s(io : IO)

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>
Source

Nested types