Class: HungryForm::Elements::RadioGroup

Inherits:
Base::OptionsElement show all
Defined in:
lib/hungryform/elements/radio_group.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
13
14
# File 'lib/hungryform/elements/radio_group.rb', line 6

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