You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a mature app using simple_form with Bootstrap 3. We are developing a new set of features where we would like to use Bootstrap 4 or maybe even 5 depending on when we launch the features, with the goal of eventually transitioning the old v3 views to use whatever new version we settle on.
Is there any suggested way of doing this? One option I guess would be to customize all of the wrappers in the generated simple_form bootstrap initializer (e.g. add a bs4_ prefix or something like that and then explicity add wrapper: :bs4_vertical_form or whatever in each call to simple form. I would like to avoid this if possible, but not if it's the only sane way.
I guess another option would be to remove the initializers and create two separate form builders and move all the initialization configuration code into the initialize method of each form builder. That's probably not great for performance but it may not be enough of an issue to matter.
Does anyone have any other ideas or suggestions? Thanks in advance.
The text was updated successfully, but these errors were encountered:
Hey @prognostikos, we're looking to do something similar, i.e. have an app running both Bootstrap 3 and 5 while we transition pages in version 3 to version 5.
@metade we ended up doing the second option - moving config out of initializers and into separate form builders. It doesn't seem to have much of an impact on performance.
It's not pretty, but here's what has worked:
classBootstrap4FormBuilder < SimpleForm::FormBuilderdefinitialize(*)configure_boostrap4_wrapperssuper@object=convert_to_model(@object)@defaults=options[:defaults]@wrapper=SimpleForm.wrapper(options[:wrapper] || SimpleForm.default_wrapper)enddefconfigure_boostrap4_wrappers# all of the config code from the initializersendend
We have a mature app using simple_form with Bootstrap 3. We are developing a new set of features where we would like to use Bootstrap 4 or maybe even 5 depending on when we launch the features, with the goal of eventually transitioning the old v3 views to use whatever new version we settle on.
Is there any suggested way of doing this? One option I guess would be to customize all of the wrappers in the generated simple_form bootstrap initializer (e.g. add a
bs4_
prefix or something like that and then explicity addwrapper: :bs4_vertical_form
or whatever in each call to simple form. I would like to avoid this if possible, but not if it's the only sane way.I guess another option would be to remove the initializers and create two separate form builders and move all the initialization configuration code into the
initialize
method of each form builder. That's probably not great for performance but it may not be enough of an issue to matter.Does anyone have any other ideas or suggestions? Thanks in advance.
The text was updated successfully, but these errors were encountered: