2010-02-06 14:41:35 -05:00
|
|
|
require 'action_view'
|
2009-12-09 15:25:12 -05:00
|
|
|
require 'simple_form/action_view_extensions/form_helper'
|
|
|
|
require 'simple_form/action_view_extensions/builder'
|
2009-12-09 13:06:59 -05:00
|
|
|
|
2009-12-09 15:25:12 -05:00
|
|
|
module SimpleForm
|
2010-07-06 16:29:26 -04:00
|
|
|
autoload :Components, 'simple_form/components'
|
|
|
|
autoload :ErrorNotification, 'simple_form/error_notification'
|
|
|
|
autoload :FormBuilder, 'simple_form/form_builder'
|
2010-10-27 13:28:05 -04:00
|
|
|
autoload :HasErrors, 'simple_form/has_errors'
|
2010-07-06 16:29:26 -04:00
|
|
|
autoload :I18nCache, 'simple_form/i18n_cache'
|
|
|
|
autoload :Inputs, 'simple_form/inputs'
|
|
|
|
autoload :MapType, 'simple_form/map_type'
|
2009-12-09 20:57:05 -05:00
|
|
|
|
2010-04-26 12:15:24 -04:00
|
|
|
# Default tag used on hints.
|
2010-01-09 08:34:52 -05:00
|
|
|
mattr_accessor :hint_tag
|
|
|
|
@@hint_tag = :span
|
|
|
|
|
2010-10-15 10:54:33 -04:00
|
|
|
# CSS class to add to all hint tags.
|
|
|
|
mattr_accessor :hint_class
|
|
|
|
@@hint_class = :hint
|
|
|
|
|
2010-04-26 12:15:24 -04:00
|
|
|
# Default tag used on errors.
|
2010-01-09 08:34:52 -05:00
|
|
|
mattr_accessor :error_tag
|
|
|
|
@@error_tag = :span
|
2009-12-09 20:57:05 -05:00
|
|
|
|
2010-10-15 11:06:32 -04:00
|
|
|
# CSS class to add to all error tags.
|
|
|
|
mattr_accessor :error_class
|
|
|
|
@@error_class = :error
|
|
|
|
|
2010-07-06 05:38:35 -04:00
|
|
|
# Method used to tidy up errors.
|
|
|
|
mattr_accessor :error_method
|
|
|
|
@@error_method = :first
|
|
|
|
|
2010-07-06 16:29:26 -04:00
|
|
|
# Default tag used for error notification helper.
|
|
|
|
mattr_accessor :error_notification_tag
|
|
|
|
@@error_notification_tag = :p
|
|
|
|
|
2009-12-09 20:57:05 -05:00
|
|
|
# Components used by the form builder.
|
|
|
|
mattr_accessor :components
|
2010-07-06 05:24:12 -04:00
|
|
|
@@components = [ :label_input, :hint, :error ]
|
2009-12-09 21:22:53 -05:00
|
|
|
|
2010-01-09 10:05:02 -05:00
|
|
|
# Series of attemps to detect a default label method for collection.
|
2009-12-09 21:22:53 -05:00
|
|
|
mattr_accessor :collection_label_methods
|
2009-12-10 20:48:29 -05:00
|
|
|
@@collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
2009-12-09 21:22:53 -05:00
|
|
|
|
2010-01-09 10:05:02 -05:00
|
|
|
# Series of attemps to detect a default value method for collection.
|
2009-12-09 21:22:53 -05:00
|
|
|
mattr_accessor :collection_value_methods
|
|
|
|
@@collection_value_methods = [ :id, :to_s ]
|
2009-12-09 21:34:45 -05:00
|
|
|
|
2010-05-27 22:52:57 -04:00
|
|
|
# You can wrap all inputs in a pre-defined tag. Default is a div.
|
2009-12-09 21:34:45 -05:00
|
|
|
mattr_accessor :wrapper_tag
|
2010-02-06 15:44:07 -05:00
|
|
|
@@wrapper_tag = :div
|
2009-12-10 17:11:15 -05:00
|
|
|
|
2010-05-27 22:52:57 -04:00
|
|
|
# You can define the class to use on all wrappers. Default is input.
|
|
|
|
mattr_accessor :wrapper_class
|
|
|
|
@@wrapper_class = :input
|
|
|
|
|
|
|
|
# You can define the class to add to the wrapper when the field has errors. Default is fieldWithErrors.
|
2010-05-24 16:38:38 -04:00
|
|
|
mattr_accessor :wrapper_error_class
|
2010-07-07 08:27:30 -04:00
|
|
|
@@wrapper_error_class = :field_with_errors
|
2010-05-24 14:52:54 -04:00
|
|
|
|
2009-12-10 17:11:15 -05:00
|
|
|
# How the label text should be generated altogether with the required text.
|
|
|
|
mattr_accessor :label_text
|
|
|
|
@@label_text = lambda { |label, required| "#{required} #{label}" }
|
2009-12-11 08:12:57 -05:00
|
|
|
|
2010-07-06 05:28:23 -04:00
|
|
|
# Whether attributes are required by default (or not).
|
|
|
|
mattr_accessor :required_by_default
|
|
|
|
@@required_by_default = true
|
|
|
|
|
2009-12-11 08:12:57 -05:00
|
|
|
# Collection of methods to detect if a file type was given.
|
|
|
|
mattr_accessor :file_methods
|
2009-12-12 20:05:51 -05:00
|
|
|
@@file_methods = [ :mounted_as, :file?, :public_filename ]
|
2009-12-11 08:53:18 -05:00
|
|
|
|
|
|
|
# Default priority for time_zone inputs.
|
|
|
|
mattr_accessor :time_zone_priority
|
|
|
|
@@time_zone_priority = nil
|
|
|
|
|
|
|
|
# Default priority for country inputs.
|
|
|
|
mattr_accessor :country_priority
|
|
|
|
@@country_priority = nil
|
2009-12-11 15:23:00 -05:00
|
|
|
|
2010-02-06 16:06:25 -05:00
|
|
|
# Maximum size allowed for inputs.
|
|
|
|
mattr_accessor :default_input_size
|
|
|
|
@@default_input_size = 50
|
|
|
|
|
2010-10-04 05:59:25 -04:00
|
|
|
# When off, do not use translations in hint, labels and placeholders.
|
|
|
|
# It is a small performance improvement if you are not using such features.
|
2010-09-30 02:12:45 -04:00
|
|
|
mattr_accessor :translate
|
|
|
|
@@translate = true
|
|
|
|
|
2010-06-04 01:41:04 -04:00
|
|
|
# Default way to setup SimpleForm. Run rails generate simple_form:install
|
2009-12-11 15:23:00 -05:00
|
|
|
# to create a fresh initializer with all configuration values.
|
|
|
|
def self.setup
|
|
|
|
yield self
|
|
|
|
end
|
2009-12-10 12:57:24 -05:00
|
|
|
end
|