Class: Formulary::HtmlForm::Fields::ColorInput

Inherits:
Input
  • Object
show all
Defined in:
lib/formulary/html_form/fields/color_input.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Input

compatible_with?, supports_required?

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_typeObject



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

def self.compatible_type
  "color"
end

Instance Method Details

#errorObject



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

def error
  return super if super.present?
  return "'#{label}' is not a valid color hex value" unless color_correct?
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  super && color_correct?
end