-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Bootstrap 3 compatibility #857
Comments
Good point @mrfoto! All the bootstrap related configuration is in your simple form initializer, so I recommend people to start playing with different configurations in the initializer and see how that works out! |
Unfortunately I can not apply the This is the third time Bootstrap has changed the way forms are built, and I doubt it's the last. |
I'm happy to apply any changes in SimpleForm that allow better bootstrap 3 integration, as long as they are not specific bootstrap features across our components. All bootstrap related configuration should be in the simple form bootstrap generated initializer. |
The bootstrap generated initializer is very good - one initial thing it misses is the ability to add a class (instead of wrap_with, for instance) in the bootstrap loader. The new bootstrap changes a few things, but most could be accomplished with that. i.e. b.use :input, class: 'form-control' @warmwaffles - you can get your specific problem working using config.label_class in simple_form.rb. Unfortunately, it's missing a config.input_class, which again, would solve some of the bootstrap form woes. |
Lets talk about |
Yes, support for adding class in initializer would be very useful with the new Bootstrap! Meanwhile this should do the trick for single forms:
|
I tried snooping around the code base to look at doing a pull request, but I couldn't figure out where to add it. |
A note for Boostrap 3: Current SimpleForm classes
This is conflicts with Bootstrap I raised this issue with Bootstrap 3: twbs/bootstrap#9067, mdo replied:
|
@warmwaffles Does config.label_class = 'control-label' not work for you? |
@AlJohri I have not tried. I will have to take a look when I get free time. |
@paav-o For form-group can you not do config.wrappers :default, :class => "input form-group" within the simple_form.rb initializer? the only problem is that you can't set the "input_class" but you can still set the wrapper class easily. To solve the input_class problem you can use this monkey patch: |
Could you guys try master branch? |
@rafaelfranca Is the master branch Rails 4 only? Any chance the PR can be backported to version 2.1? It would help immensely. |
@AlJohri yes. |
I think so, feel free to send a pull request cherry-picking that commit to 2-1 branch making sure all tests pass (although I'd recommend updating to rails 4 ;) |
@AlJohri actually, do you plan to use bootstrap 3 with rails 3.2? |
@carlosantoniodasilva I definitely plan to use BS3 with Rails 3.2 |
@johnnyshields can you give a bit more context please? I guess I can't see a lot of people migrating existing apps from bootstrap 2 to 3, the same way I'd not expect people starting new apps on Rails 3.2 nowadays, so this kinda conflicts, that's why I ask 😄 |
I think most apps these days are feeling the need for truly responsive design, and that's not really possible with BS2. Also, the whole ecosystem will move on and any app that continues to grow will be left without the community benefits and maintaining dependencies on their own. All that to say, I think many people will upgrade (eventually), including me. |
@carlosantoniodasilva I'm running an app in production currently that uses Rails 3.2 and BS 3 RC1. In my view, Rails 4 is not such a huge improvement over Rails 3.2. Things that Rails 4 offers like strong parameters and turbolinks I can get as gems as I need them, and I do not see a huge driver to migrate to Rails 4 immediately. Conversely, the BS3 grid system is a massive improvement over BS2 and cannot be backported. As soon as I saw BS3 RC I immediately implemented across my entire app and removed ~1000+ lines of mobile CSS hacks that had accumulated in my app--and after a few days of squashing bugs the app actually looks better and is more responsive than before! BS3 gave my team a productivity boost from the moment I added it, since my designer can spend less time hacking mobile stuff. A last point is that some gems are still not Rails 4 compatible (or Rails 4 compat is "experimental"). When it comes to migrations, it's really a matter of waiting until the dependent last gem is ready before you can implement. For BS3, the only dependency I have is SimpleForms, and I've removed it / added hacks for now (i.e. using #input_field instead of #input) until it's ready. |
@rafaelfranca Just how exactly does c14bc3e close this? It's still not BS3 compatible... |
@mrfoto agreed, it seems to add the class to the wrapper as well as the input itself |
@neb2000 yeah, but that wasn't the issue here 😄 |
So please tell what is missing.
|
Well the issue was Bootstrap 3 compatibility 😃 |
@mrfoto I think generating initializer is hardly the problem here, as long as there's a way for you to configure the gem to generate bootstrap3 compatible markup. |
@neb2000 I don't know what's the problem but as long as they don't exist, the issue shouldn't be closed |
Also seeing the class getting added to the wrapper when using this, which is problematic for BS3. Just echoing others' comments here. Thanks for your hard work. |
@JoshMcCullough Same here - I just can't seem to get it to generate the relevant wrappers for a horizontal-form. When setting the form class to form-vertical, it works as expected with a vertical form, but I figure out how to make it generate the extra wrappers needed for a horizontal form. Am I missing something, or is it currently not possible? I don't see anything in the above Gists that would make it possible in my mind. |
@JoshMcCullough it's not generating the horizontal form wrapper. It stays vertical even after I have applied the horizontal form class to it. "Form-control" works but form-horizontal doesn't. I also tried
and still no change to my form. |
I've found another solution that, although hacky, sort of works for horizontal forms here: https://gist.github.com/adamico/6510093 |
@JoshMcCullough @diegodurs Thanks for the temporary solution! |
@diegodurs You're welcome! |
For active admin use
To overwrite the actual simple_form classes instead of creating global new ones, which interfere with formtastic and thus active admin. The |
So all the code examples above for an updated initialiser what is the status of bootstrap 3 support now?
I used this initialiser: Thanks in advanche |
@rubytastic it's still being worked on heartcombo/simple_form-bootstrap#28 come help us! :) |
None of my alert messages have a color, can anyone help with that? |
👍 on this fix. |
👍 Looking forward for the final version. |
👍 Same! Hope it's soon 👯 |
👍 |
https://github.com/kolodovskyy/simple_form_bootstrap3.git |
@kolodovskyy Thanks a lot, I will definitely check it out. Are there any known shortcomings? In general, I think the documentation is a bit small, e.g. I have to browse the source code to see what wrappers are available. |
yes, 2-3 days i will show a few examples for each wrappers. Shortcomings... maybe not, but need some additional wrappers for input-group and maybe remove one extra tag with datepicker. All other is OK with many form used in our project. |
We just released Simple Form 3.1.0.rc1 with Bootstrap 3 support. Please give a try. http://blog.plataformatec.com.br/2014/04/bootstrap-3-support-for-simple-form/ |
@rafaelfranca ❤️ will try it soon. |
form-horizontal doesn't work with Simple Form 3.1.0.rc1 on Rails 4.1.1 and Bootstrap 3 (bootstrap-sass 3.1.1.1) |
@ReinierKorth we need more information about this. It seems working fine at http://simple-form-bootstrap.plataformatec.com.br/ |
The only way I can get the form-horizontal layout working is by setting config.default_wrapper = :horizontal_form (instead of vertical_form) inside the simple_form_bootstrap.rb but then all my form with be horizontal no matter what class i give them. |
I was just doing that :) With the extra wrappers it works. Didn't know I had to include extra wrappers. Thanks for your help :) |
What's wrong with 'submit button' in horizontal_form? It looks alone, but must be in a row with other inputs. How to add offset-class div to the button? |
|
Button submit must be wrapped by div with offset class. If I just add class to the button it doesn't work correctly. |
So it is also easy to do: <div class='bla'>
<%= f.button :submit %>
</div> |
Actually, I know how html tags works, really ) Look, all simple_forms goodness is a simple code, like this: = f.input :foo If I should use additional tags (like your example above), it became looks like usual code, not pretty at all )) Also, it looks like only horizontal_form has that issue, and I just thought it's a forgotten submit button bug. Other words, may be some wrapper must be added to simple_form_bootstrap.rb, or something. Seems no ) |
I see. For us Simple Form is a set of helpers but this doesn't mean you would not need to use HTML tags or other helpers. It is totally fine to use additional tags and we really recommend to do this.
We could change the |
Sounds reasonably, thanks for the gem ) |
RC1 is out and it brings a lot of changes to form elements. Maybe someone should start making this compatible?
The text was updated successfully, but these errors were encountered: