question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems with Bootstrap 4 formatting hack in helper.FormHelper

See original GitHub issue

In 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:

  1. Fragile: Hardcoding like this assumes Bootstrap 4’s API doesn’t change (it does)
  2. Unforgiving: Doesn’t allow for any variation in template design
  3. Really Unforgiving: No way to override this behavior
  4. 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:closed
  • Created 7 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
yunticommented, Sep 14, 2016

Presumably you could set wrapper_class at the helper level rather than at every field in layout to keep things DRY?

1reaction
carltongibsoncommented, Sep 8, 2016

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.)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found