stouset / twitter_bootstrap_form_for

A Rails FormBuilder DSL for generating Twitter Bootstrap forms
https://github.com/stouset/twitter_bootstrap_form_for
MIT License
409 stars 110 forks source link

Different solution to inline elements #29

Closed kylecrum closed 12 years ago

kylecrum commented 12 years ago

Howdy, I saw that you just fixed the attribute nesting error, but I was working on another alternative before you pushed those changes. Probably should have said something, but, you know how that goes sometimes. Anyway, one of the problems for me, at least, with returning a default rails builder is that I have subclasses your TwitterBootstrapFormFor::FormBuilder form builder so that I can do nifty things like automatically marking fields as required, populating dropdowns, etc. In inline forms, I lose all the stuff that I do in my subclassed form builder because it returns the default builder, which is no fun for me. Instead, I have it just yield the current instance of the form builder class that way we still have access to all the same nifty things from the form builder we are using. So, ya, there you go. Let me know what you think.

stouset commented 12 years ago

Will take a look. Give me a few days.

Thanks!

stouset commented 12 years ago

I actually like a lot of the changes in here, but I'm confused one one thing: since you're just using the same TwitterBootstrapFormFor::FormBuilder in the inline inputs, doesn't this force them to get a label?

kylecrum commented 12 years ago

It shouldn't. While doing anything within the block passed to the inline command, an instance variable @render_inline is set to true. When that instance variable is set, all of the subsequent field calls will skip the label and div wrapper rendering. Check out the div_wrapper_with_label method.

stouset commented 12 years ago

I'm going to make some tweaks, but I think I'm going to replace the approach I went with with this one. Thanks for the contribution!

kylecrum commented 12 years ago

Cool. No problem. Assuming you keep the essence of the changes, I think this can create a solution to issue #28. Once you make your changes, I can add on other changes to fix that problem.

derekprior commented 12 years ago

I like this approach as well... and I hacked together the last one ;)