b12ad4abc4
With this API, Simple Form will be possible to add custom components. 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 InpoutGroupComponent def preprend ... 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 %> |
||
---|---|---|
.. | ||
custom_components_test.rb | ||
label_test.rb |