Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is everything configured "globally" rather than on the FormBuilder? #1180

Open
jensljungblad opened this issue Dec 19, 2014 · 3 comments

Comments

@jensljungblad
Copy link

All config regarding how to render the forms are stored on the SimpleForm module. This makes it really difficult to render different kinds of forms, if I've understood the README correctly.

I have two sections of my app, and forms use different markup in these two sections.

The wrappers seem to be configurable, so I can create two wrappers for my two different form styles, however, there's lots of other config that is not specified per wrapper. The boolean_style and the button_class for instance.

What I don't understand is why these things are configured in an initializer instead of in the FormBuilder class? That way I could just create two subclasses and pass them to the simple_form_for helper.

@rafaelfranca
Copy link
Collaborator

To be honest because nobody needed to have two forms in the same application with different configurations.

Almost every global configuration can be done at wrapper level too so you can have different configurations for different forms using the wrapper API. Some options were not moved yet but I plan to kill them in a future release.

@jensljungblad
Copy link
Author

Yeah it would be great if everything could be configured at the wrapper level. Would also be nice if there were mentions in the README on how to do it.

On a more general note, how come so many gems use this kind of global configuration? I've been building a bunch of apps using Rails engines, and they don't go so good together with global config. Oftentimes I find myself wanting a different setup per app engine.

@rafaelfranca
Copy link
Collaborator

On a more general note, how come so many gems use this kind of global configuration? I've been building a bunch of apps using Rails engines, and they don't go so good together with global config. Oftentimes I find myself wanting a different setup per app engine.

I guess it is a historical reason. Simple Form for example was created even before Rails Engines existed. It is not easy to do this kind of design change in a stable gem so we had to do it gradually. My plan is to use wrappers API to define all the configurations, but this doesn't fix the engine problem yet, but I believe it is possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants