Class: Formulary::HtmlForm::Fields::Select

Inherits:
Field
  • Object
show all
Defined in:
lib/formulary/html_form/fields/select.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Field

#get_value_from_data_field, #initialize, #is_hidden?, #label, #name, #set_value, supports_required?

Constructor Details

This class inherits a constructor from Formulary::HtmlForm::Fields::Field

Class Method Details

.compatible_with?(element) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/formulary/html_form/fields/select.rb', line 3

def self.compatible_with?(element)
  element.name == "select"
end

Instance Method Details

#errorObject



11
12
13
# 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?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/formulary/html_form/fields/select.rb', line 7

def valid?
  valid_values.include?(@value)
end