bootstrap-ruby / bootstrap_form

Official repository of the bootstrap_form gem, a Rails form builder that makes it super easy to create beautiful-looking forms using Bootstrap 5.
MIT License
1.64k stars 352 forks source link

Add `bootstrap_fields_for` and `bootstrap_fields` form helpers. #699

Closed donv closed 9 months ago

donv commented 10 months ago

Fixes #283

donv commented 9 months ago

We should have test cases for the new method -- I expect a few tests, since this method has optional arguments, and our long list of options. I not proposing we completely re-test BootstrapForm::FormBuilder, but maybe consider some of the key use cases for this method and where they might interact with how our form builder works.

I have added a couple of tests to see that it works across the test matrix. The new method actually has no options of itself, it only forwards arguments to the upstream fields_for method, so I don't see what variants are useful to test. I also added the bootstrap_fields method since it is trivial to implement.

I'm curious about the :builder option. I quickly scanned the Rails docs but didn't see an explicit mention. Did I just miss it?

The concrete option is not mentioned in the method documentation comment. The builder is barely mentioned, but is clearly there in the code:

https://github.com/rails/rails/blob/main/actionview/lib/action_view/helpers/form_helper.rb#L1614C11-L1614C11

donv commented 9 months ago

I'm curious about the :builder option. I quickly scanned the Rails docs but didn't see an explicit mention. Did I just miss it?

I found an example here:

lcreid commented 9 months ago

Thanks for digging up some details about the builder argument. Maybe the assumption is that one understands that all those helpers are similar to the form_for helper that has the builder argument.

Also, I appreciate you thinking through the testing. I suspected it might be hard to determine what to test, but sometimes I think it's useful to ask people to take one more run at the problem before putting it to bed. Thanks for doing the thinking and researching.

donv commented 9 months ago

Thanks for digging up some details about the builder argument. Maybe the assumption is that one understands that all those helpers are similar to the form_for helper that has the builder argument.

Also, I appreciate you thinking through the testing. I suspected it might be hard to determine what to test, but sometimes I think it's useful to ask people to take one more run at the problem before putting it to bed. Thanks for doing the thinking and researching.

My pleasure! 😄