frozen_string_literal: true
| CUSTOM_INPUT_DEPRECATION_WARN | = | <<-WARN %{name} method now accepts a `wrapper_options` argument. The method definition without the argument is deprecated and will be removed in the next Simple Form version. Change your code from: def %{name} to def %{name}(wrapper_options) See https://github.com/plataformatec/simple_form/pull/997 for more information. WARN |
| VERSION | = | "4.1.0".freeze |
Includes a component to be used by Simple Form. Methods defined in a component will be exposed to be used in the wrapper as Simple::Components
Examples
# The application needs to tell where the components will be.
Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
# Create a custom component in the path specified above.
# lib/components/input_group_component.rb
module InputGroupComponent
def prepend
...
end
def append
...
end
end
SimpleForm.setup do |config|
# Create a wrapper using the custom component.
config.wrappers :input_group, tag: :div, error_class: :error do |b|
b.use :label
b.optional :prepend
b.use :input
b.use :append
end
end
# Using the custom component in the form.
<%= simple_form_for @blog, wrapper: input_group do |f| %>
<%= f.input :title, prepend: true %>
<% end %>
Default way to setup Simple Form. Run rails generate simple_form:install to create a fresh initializer with all configuration values.
Define a new wrapper using SimpleForm::Wrappers::Builder and store it in the given name.