class Formulary::HtmlForm::Fields::Select

Public Class Methods

compatible_with?(element) click to toggle source
# File lib/formulary/html_form/fields/select.rb, line 3
def self.compatible_with?(element)
  element.name == "select"
end

Public Instance Methods

error() click to toggle source
# File lib/formulary/html_form/fields/select.rb, line 11
def error
  return "'#{label}' must be chosen from the available options" unless valid?
end
valid?() click to toggle source
# File lib/formulary/html_form/fields/select.rb, line 7
def valid?
  valid_values.include?(@value)
end

Protected Instance Methods

valid_values() click to toggle source
# File lib/formulary/html_form/fields/select.rb, line 17
def valid_values
  @valid_values ||= \
    @element.css("option").map do |option|
      option["value"] ? option["value"] : option.text
    end
end