Module: SimpleForm
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/simple_form.rb,
lib/simple_form/inputs.rb,
lib/simple_form/helpers.rb,
lib/simple_form/version.rb,
lib/simple_form/map_type.rb,
lib/simple_form/wrappers.rb,
lib/simple_form/components.rb,
lib/simple_form/i18n_cache.rb,
lib/simple_form/inputs/base.rb,
lib/simple_form/form_builder.rb,
lib/simple_form/wrappers/many.rb,
lib/simple_form/wrappers/root.rb,
lib/simple_form/wrappers/single.rb,
lib/simple_form/components/hints.rb,
lib/simple_form/components/html5.rb,
lib/simple_form/helpers/disabled.rb,
lib/simple_form/helpers/readonly.rb,
lib/simple_form/helpers/required.rb,
lib/simple_form/wrappers/builder.rb,
lib/simple_form/components/errors.rb,
lib/simple_form/components/labels.rb,
lib/simple_form/helpers/autofocus.rb,
lib/simple_form/inputs/file_input.rb,
lib/simple_form/inputs/text_input.rb,
lib/simple_form/components/min_max.rb,
lib/simple_form/components/pattern.rb,
lib/simple_form/error_notification.rb,
lib/simple_form/helpers/validators.rb,
lib/simple_form/inputs/block_input.rb,
lib/simple_form/inputs/range_input.rb,
lib/simple_form/components/readonly.rb,
lib/simple_form/inputs/hidden_input.rb,
lib/simple_form/inputs/string_input.rb,
lib/simple_form/components/maxlength.rb,
lib/simple_form/inputs/boolean_input.rb,
lib/simple_form/inputs/numeric_input.rb,
lib/simple_form/inputs/password_input.rb,
lib/simple_form/inputs/priority_input.rb,
lib/simple_form/components/label_input.rb,
lib/simple_form/inputs/date_time_input.rb,
lib/simple_form/components/placeholders.rb,
lib/simple_form/inputs/collection_input.rb,
lib/generators/simple_form/install_generator.rb,
lib/simple_form/action_view_extensions/builder.rb,
lib/simple_form/inputs/collection_select_input.rb,
lib/simple_form/action_view_extensions/form_helper.rb,
lib/simple_form/inputs/collection_check_boxes_input.rb,
lib/simple_form/inputs/collection_radio_buttons_input.rb,
lib/simple_form/inputs/grouped_collection_select_input.rb
Defined Under Namespace
Modules: ActionViewExtensions, Components, Generators, Helpers, I18nCache, Inputs, MapType, Wrappers Classes: ErrorNotification, FormBuilder, WrapperNotFound
Constant Summary collapse
- DEPRECATED =
SETUP
%w(hint_tag hint_class error_tag error_class error_notification_id wrapper_tag wrapper_class wrapper_error_class components html5)
- VERSION =
"2.1.3".freeze
- @@error_method =
:first
- @@error_notification_tag =
:p
- @@error_notification_class =
:error_notification
- @@collection_label_methods =
[ :to_label, :name, :title, :to_s ]
- @@collection_value_methods =
[ :id, :to_s ]
- @@collection_wrapper_tag =
nil
- @@collection_wrapper_class =
nil
- @@item_wrapper_tag =
:span
- @@item_wrapper_class =
nil
- @@label_text =
lambda { |label, required| "#{required} #{label}" }
- @@label_class =
nil
- @@boolean_style =
:inline
- @@form_class =
:simple_form
- @@generate_additional_classes_for =
[:wrapper, :label, :input]
- @@required_by_default =
true
- @@browser_validations =
true
- @@file_methods =
[ :mounted_as, :file?, :public_filename ]
- @@input_mappings =
nil
- @@wrapper_mappings =
nil
- @@time_zone_priority =
nil
- @@country_priority =
nil
- @@default_input_size =
50
- @@translate_labels =
true
- @@inputs_discovery =
true
- @@cache_discovery =
defined?(Rails) && !Rails.env.development?
'button'
- @@default_wrapper =
:default
- @@wrappers =
{}
- @@deprecated =
[]
Class Method Summary collapse
- .additional_classes_for(component) ⇒ Object
-
.build(options = {}) {|builder| ... } ⇒ Object
Builds a new wrapper using SimpleForm::Wrappers::Builder.
- .deprecation_warn(message) ⇒ Object
-
.setup {|_self| ... } ⇒ Object
Default way to setup SimpleForm.
- .translate ⇒ Object
- .translate=(value) ⇒ Object
-
.wrapper(name) ⇒ Object
Retrieves a given wrapper.
-
.wrappers(*args, &block) ⇒ Object
Define a new wrapper using SimpleForm::Wrappers::Builder and store it in the given name.
Instance Method Summary collapse
-
#default_wrapper ⇒ Object
WRAPPER CONFIGURATION The default wrapper to be used by the FormBuilder.
Class Method Details
.additional_classes_for(component) ⇒ Object
209 210 211 |
# File 'lib/simple_form.rb', line 209 def self.additional_classes_for(component) generate_additional_classes_for.include?(component) ? yield : [] end |
.build(options = {}) {|builder| ... } ⇒ Object
Builds a new wrapper using SimpleForm::Wrappers::Builder.
164 165 166 167 168 169 |
# File 'lib/simple_form.rb', line 164 def self.build(={}) [:tag] = :div if [:tag].nil? builder = SimpleForm::Wrappers::Builder.new() yield builder SimpleForm::Wrappers::Root.new(builder.to_a, ) end |
.deprecation_warn(message) ⇒ Object
205 206 207 |
# File 'lib/simple_form.rb', line 205 def self.deprecation_warn() ActiveSupport::Deprecation.warn "[SIMPLE_FORM] #{}", caller end |
.setup {|_self| ... } ⇒ Object
Default way to setup SimpleForm. Run rails generate simple_form:install to create a fresh initializer with all configuration values.
215 216 217 218 219 220 221 222 223 |
# File 'lib/simple_form.rb', line 215 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 |
.translate ⇒ Object
200 201 202 203 |
# File 'lib/simple_form.rb', line 200 def self.translate deprecation_warn "SimpleForm.translate is disabled in favor of translate_labels" self.translate_labels end |
.translate=(value) ⇒ Object
195 196 197 198 |
# File 'lib/simple_form.rb', line 195 def self.translate=(value) deprecation_warn "SimpleForm.translate= is disabled in favor of translate_labels=" self.translate_labels = value end |
.wrapper(name) ⇒ Object
Retrieves a given wrapper
143 144 145 |
# File 'lib/simple_form.rb', line 143 def self.wrapper(name) @@wrappers[name.to_sym] or raise WrapperNotFound, "Couldn't find wrapper with name #{name}" end |
.wrappers(*args, &block) ⇒ Object
Define a new wrapper using SimpleForm::Wrappers::Builder and store it in the given name.
153 154 155 156 157 158 159 160 161 |
# File 'lib/simple_form.rb', line 153 def self.wrappers(*args, &block) if block_given? = args. name = args.first || :default @@wrappers[name.to_sym] = build(, &block) else @@wrappers end end |
Instance Method Details
#default_wrapper ⇒ Object
WRAPPER CONFIGURATION The default wrapper to be used by the FormBuilder.
138 |
# File 'lib/simple_form.rb', line 138 mattr_accessor :default_wrapper |