Problems with Bootstrap 4 formatting hack in helper.FormHelper
See original GitHub issueIn Cookiecutter Django we’ve discovered that when using Bootstrap 4, there is a bit of code in Crispy Forms which is causing us a lot of problems. This code is caused us serious problems with all our forms:
class FormHelper(DynamicLayoutHandler):
...
if template_pack == 'bootstrap4':
grid_colum_matcher = re.compile('\w*col-(xs|sm|md|lg|xl)-\d+\w*')
using_grid_layout = (grid_colum_matcher.match(self.label_class) or
grid_colum_matcher.match(self.field_class))
if using_grid_layout:
items['using_grid_layout'] = True
Our issues with the above approach:
- Fragile: Hardcoding like this assumes Bootstrap 4’s API doesn’t change (it does)
- Unforgiving: Doesn’t allow for any variation in template design
- Really Unforgiving: No way to override this behavior
- Undocumented: No mention in the documentation, or it’s too hard for me to find
Right now our solution is to implement our own hack to get around this behavior, which is not ideal and something we want to fix.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Problems with Bootstrap 4 formatting hack in helper.FormHelper #613
In Cookiecutter Django we've discovered that when using Bootstrap 4, there is a bit of code in Crispy Forms which is causing us...
Read more >Add Cancel and Delete buttons to django-crispy-forms | j.mo
I've been using django-crispy-forms with Bootstrap 4 on a little Django ... ModelForm): helper = FormHelper() helper.layout = Layout( ...
Read more >Bootstrap 4 Cheat Sheet - The ultimate list of Bootstrap classes
Quickly find your Bootstrap classes on this interactive Bootstrap cheat sheet. It includes code samples and live preview of elements.
Read more >Bootstrap 3: Form "required" not working in mobile devices
I'm working on a form I styled with bootstrap and connected to google docs doing a little hack. The form works great when...
Read more >Migrating from CakePHP 1.2 to 1.3
Each section contains relevant information for the modifications made ... depends on them you must define them in app/config/bootstrap.php.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Presumably you could set
wrapper_class
at the helper level rather than at every field in layout to keep things DRY?OK. Awesome.
I think adjusting so it’s right and then adding a note to the Change Log so people know how to update is the best approach.
(Bootstrap 4 support is beta at least as long as Bootstrap 4 is, and probably until we’ve had some feedback from real world usage to go with that too.)