SETUP
# File lib/simple_form.rb, line 206 def self.additional_classes_for(component) generate_additional_classes_for.include?(component) ? yield : [] end
Builds a new wrapper using SimpleForm::Wrappers::Builder.
# File lib/simple_form.rb, line 161 def self.build(options={}) options[:tag] = :div if options[:tag].nil? builder = SimpleForm::Wrappers::Builder.new(options) yield builder SimpleForm::Wrappers::Root.new(builder.to_a, options) end
# File lib/simple_form.rb, line 202 def self.deprecation_warn(message) ActiveSupport::Deprecation.warn "[SIMPLE_FORM] #{message}", caller end
Default way to setup SimpleForm. Run rails generate simple_form:install to create a fresh initializer with all configuration values.
# File lib/simple_form.rb, line 212 def self.setup yield self unless @@deprecated.empty? raise "[SIMPLE FORM] Your SimpleForm initializer file is using the following methods: #{@@deprecated.to_sentence}. " << "Those methods are part of the outdated configuration API. Updating to the new API is easy and fast. " << "Check for more info here: https://github.com/plataformatec/simple_form/wiki/Upgrading-to-Simple-Form-2.0" end end
# File lib/simple_form.rb, line 197 def self.translate deprecation_warn "SimpleForm.translate is disabled in favor of translate_labels" self.translate_labels end
# File lib/simple_form.rb, line 192 def self.translate=(value) deprecation_warn "SimpleForm.translate= is disabled in favor of translate_labels=" self.translate_labels = value end
Retrieves a given wrapper
# File lib/simple_form.rb, line 140 def self.wrapper(name) @@wrappers[name.to_sym] or raise WrapperNotFound, "Couldn't find wrapper with name #{name}" end
Define a new wrapper using SimpleForm::Wrappers::Builder and store it in the given name.
# File lib/simple_form.rb, line 150 def self.wrappers(*args, &block) if block_given? options = args.extract_options! name = args.first || :default @@wrappers[name.to_sym] = build(options, &block) else @@wrappers end end