Class: Formulary::HtmlForm::Fields::Input

Inherits:
Field
  • Object
show all
Defined in:
lib/formulary/html_form/fields/input.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

Constructor Details

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

Class Method Details

.compatible_with?(element) ⇒ Boolean

Returns:

  • (Boolean)


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

def self.compatible_with?(element)
  element.name == "input" &&
  element.attributes["type"].value == compatible_type
end

.supports_required?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/formulary/html_form/fields/input.rb', line 8

def self.supports_required?
  true
end

Instance Method Details

#errorObject



16
17
18
19
# File 'lib/formulary/html_form/fields/input.rb', line 16

def error
  return super if super.present?
  return "'#{label}' does not match the expected format" unless pattern_correct?
end

#valid?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/formulary/html_form/fields/input.rb', line 12

def valid?
  super && pattern_correct?
end