Sha256: 8c7268100ae471e79832bc56e4c1ef60b4952b91320a83841dba9f296d98ad5b
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 KB
Contents
module Storefront class Form class Base include Storefront::LocaleHelper include Storefront::AttributeHelper def initialize(options = {}) @template = options[:template] @model = options[:model] @attribute = options[:attribute] @parent_index = options[:parent_index] @index = options[:index] @tabindex = options[:tabindex] @access_keys = options[:access_keys] @attributes = clone_attributes(options.except(:template, :model, :attribute, :access_keys, :index, :tabindex)) end protected attr_accessor :template, :model, :attribute, :index, :parent_index attr_accessor :attributes, :value, :label, :access_keys, :tabindex, :input_type def default_options!(options = {}) options[:model] ||= model options[:index] ||= index options[:attribute] ||= attribute options[:template] ||= template options end def config Storefront.configuration end alias_method :storefront_config, :config def value? @value.present? end def localize(key, attribute, default, options = {}) if default.present? return default.to_s unless default.is_a?(::Symbol) attribute = default end t?(attribute, options.reverse_merge(:scope => :"forms.#{key}", :model => model.object)) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems