Class: Kithe::FormBuilder
- Inherits:
-
SimpleForm::FormBuilder
- Object
- SimpleForm::FormBuilder
- Kithe::FormBuilder
- Defined in:
- app/simple_form_enhancements/kithe/form_builder.rb
Overview
A SimpleForm::FormBuilder sub-class with custom kithe features:
-
repeatable_model_input
If you use the ‘kithe_form_for` helper instead of `simple_form_for`, you get a custom Kithe::FormBuilder in your simple_form building.
Instance Method Summary collapse
-
#repeatable_attr_input(attr_name, html_attributes: nil, build: nil, simple_form_input_args: {}) {|builder| ... } ⇒ Object
Produce a form input for a repeatable attr_json field.
Instance Method Details
#repeatable_attr_input(attr_name, html_attributes: nil, build: nil, simple_form_input_args: {}) {|builder| ... } ⇒ Object
Produce a form input for a repeatable attr_json field. Takes care of the add/remove UI apparatus – generated HTML assumes Bootstrap 4, and simple_form Bootstrap config with a :vertical_collection wrapper.
See the [Forms Guide](../../../guides/forms.md) for more usage information.
Actual implementation code is over in Kithe::RepeatableInputGenerator
This is a method rather than a simple form component mostly becuase simple form components don’t allow a block param like this, and that works out so well here.
FUTURE: Provide options to customize classes and labels on generated wrapping UI apparatus.
39 40 41 42 43 44 45 |
# File 'app/simple_form_enhancements/kithe/form_builder.rb', line 39 def repeatable_attr_input(attr_name, html_attributes: nil, build: nil, simple_form_input_args: {}, &block) #repeatable_main_content(attr_name, &block) Kithe::RepeatableInputGenerator.new(self, attr_name, block, html_attributes: html_attributes, simple_form_input_args: simple_form_input_args, build: build).render end |