-
Notifications
You must be signed in to change notification settings - Fork 356
Support for Rails 5.1 form_with
#346
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
Conversation
) * Support :prepend and :append for the `select` helper Fixes bootstrap-ruby#147 * Bootstrap 4 has renamed `control-label` to `form-control-label`
The main changes were around the fact that `form_with` doesn't automatically add class and id attributes in many places that the other form builders did. Added a `for:` to the label options if an ID was specified for the input element, so that the label would get the correct value for the `for` attribute. Sub-classed the form builder to override methods to make `form_with` work without the default Rails-generated DOM IDs.
The `bootstrap_form_with` helper uses Ruby 2+ syntax. I put a test for the Rails version, so the helper is only parse if running Rails 5.1+.
|
This latest update removes the need for the |
|
I have a branch in my own fork that back ports |
Remove confusing comment. Remove some more unnecessary diffs.
|
Sorry, folks. That last commit may have caused more problems than it solved. Let me look at this some more... |
|
I think somewhere along the way master and bootstrap-4 branches diverged in a few formatting matters, mostly around whether single or double-quotes were used for strings. I believe that my last commit to this PR makes the two branches more consistent. If someone wants me to change this back, I'd be happy to. Just let me know. |
16d82d6 to
a68a242
Compare
|
@mattbrictson @GBH Is there a way to change this PR to merge to master, or should I just close this and submit a new PR against master? |
|
I feel this PR is quite outdated. Probably easier to start a new one form master branch. |
This PR adds a new helper
bootstrap_form_withto support the Rails 5.1form_withhelper (#326). I consider this PR to be more of a "proof of concept", so I hope I get lots of comments.There are a number of new test files. Out of an abundance of caution, I chose to duplicate many of the existing tests for
bootstrap_form_forandbootstrap_form_tag, but usingbootstrap_form_with. In addition, for the new tests I wanted to test everything with and without specifying a DOM id as an argument to the field helpers. (The Rails helpers when used withform_withdon't generate the default DOM ids like they do underform_for.)In addition to the automated tests, I've integrated this into an application I'm building. The application is working, except for the problem mentioned in the next paragraph.
I implemented a subclass
BootstrapForm::FormBuilderFormWithof the existingBootstrapForm::FormBuilderclass to handle some of the new functionality. The application that I'm using as a "proof of concept" forbootstrap_form_withuses a custom form builder that was implemented on top ofBootstrapForm::FormBuilder. The way I implemented the subclass is clumsy when a developer needs to further subclass theBootstrapFormform builder. I'm open to suggestions as to a better way. In the meantime, I'll try some other approaches.