Sha256: 2d7bd551668a9661c25ac33244cf6bf863ef5a16fb6c6f47122b21596fd60169
Contents?: true
Size: 847 Bytes
Versions: 3
Compression:
Stored size: 847 Bytes
Contents
module SimpleForm module Helpers module Required private def attribute_required? @required end def calculate_required if !options[:required].nil? options[:required] elsif has_validators? (attribute_validators + reflection_validators).any? do |v| v.kind == :presence && valid_validator?(v) end else attribute_required_by_default? end end # Whether this input is valid for HTML 5 required attribute. def has_required? attribute_required? && SimpleForm.html5 && SimpleForm.browser_validations end def attribute_required_by_default? SimpleForm.required_by_default end def required_class attribute_required? ? :required : :optional end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
simple_form-1.5.2 | lib/simple_form/helpers/required.rb |
simple_form-1.5.1 | lib/simple_form/helpers/required.rb |
simple_form-1.5.0 | lib/simple_form/helpers/required.rb |