Sha256: 2e89ed8e75a1f3b5b526300be8bce2cddbaa73fec47365b2b28d35202f849bb4
Contents?: true
Size: 1012 Bytes
Versions: 1
Compression:
Stored size: 1012 Bytes
Contents
class HungryForm class BaseActiveElement < BaseElement attr_accessor :error, :value, :required alias_method :required?, :required def initialize(name, parent, resolver, options = {}, &block) super self.error = '' # Filter only the options that are present in the HungryForm::Validator singleton class @validation_rules = options.select { |key, val| HungryForm::Validator.respond_to?(key) } if parent.visible? self.required = options[:required] || false else self.required = false end self.value = resolver.params.has_key?(self.name)? resolver.params[self.name] : options[:value] end def valid? self.error = '' return true if !visible? is_valid = true @validation_rules.each do |key, rule| error = HungryForm::Validator.send(key, self, rule) || '' unless error.empty? is_valid = false break end end is_valid end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hungryform-0.0.2 | lib/hungryform/elements/base_active_element.rb |