Class: HungryForm::Elements::SelectField

Inherits:
Base::OptionsElement show all
Defined in:
lib/hungryform/elements/select_field.rb

Instance Attribute Summary

Attributes inherited from Base::OptionsElement

#options

Attributes inherited from Base::ActiveElement

#error, #required, #value

Attributes inherited from Base::Element

#attributes, #dependency, #label, #name, #placeholders, #resolver, #visible

Instance Method Summary collapse

Methods inherited from Base::OptionsElement

#initialize

Methods inherited from Base::ActiveElement

#clear_error, #initialize, #invalid?, #valid?, #validate_rule

Methods inherited from Base::Element

#configuration, #dependency_json, #initialize

Methods included from Base::Hashable

included, #to_hash

Constructor Details

This class inherits a constructor from HungryForm::Elements::Base::OptionsElement

Instance Method Details

#set_valueObject

Sets a value of the element Checks the value from the resolver params against the available options



6
7
8
9
10
11
12
# File 'lib/hungryform/elements/select_field.rb', line 6

def set_value
  if resolver.params.key?(name)
    self.value = resolver.params[name] if acceptable_values?
  else
    self.value = attributes.delete(:value)
  end
end