module SimpleForm
def self.include_component(component)
<% end %>
<%= f.input :title, prepend: true %>
<%= simple_form_for @blog, wrapper: input_group do |f| %>
# Using the custom component in the form.
end
end
b.use :append
b.use :input
b.optional :prepend
b.use :label
config.wrappers :input_group, tag: :div, error_class: :error do |b|
# Create a wrapper using the custom component.
SimpleForm.setup do |config|
end
end
...
def append
end
...
def prepend
module InputGroupComponent
# lib/components/input_group_component.rb
# Create a custom component in the path specified above.
Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
# The application needs to tell where the components will be.
Examples
component will be exposed to be used in the wrapper as Simple::Components
Includes a component to be used by Simple Form. Methods defined in a
def self.include_component(component) if Module === component SimpleForm::Inputs::Base.include(component) else raise TypeError, "SimpleForm.include_component expects a module but got: #{component.class}" end end