Sha256: 35af6a59869e8766f9146091f1f93b068815530026e143b6e42212ca77f70a9a
Contents?: true
Size: 929 Bytes
Versions: 1
Compression:
Stored size: 929 Bytes
Contents
module HungryForm module Elements class SelectField < Base::OptionsElement attr_accessor :multiple alias_method :multiple?, :multiple hashable :multiple def initialize(name, parent, resolver, attributes = {}, &block) self.multiple = attributes[:multiple] || false super end # Sets a value of the element # Checks the value from the resolver params against the available options def set_value if resolver.params.key?(name) # Check if all values present in the options if multiple? acceptable_values = (resolver.params[name] - options.keys).empty? else acceptable_values = options.keys.include?(resolver.params[name]) end self.value = resolver.params[name] if acceptable_values else self.value = @attributes[:value] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hungryform-0.0.4 | lib/hungryform/elements/select_field.rb |