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
Only show MultiField alert if fields have errors #980
base: main
Are you sure you want to change the base?
Conversation
to indicate if multifield fields have errors
if multifield fields have errors
Codecov Report
@@ Coverage Diff @@
## master #980 +/- ##
==========================================
+ Coverage 96.51% 96.52% +<.01%
==========================================
Files 24 24
Lines 2729 2732 +3
Branches 241 241
==========================================
+ Hits 2634 2637 +3
Misses 54 54
Partials 41 41
Continue to review full report at Codecov.
|
Could I suggest a couple of other options to try fix this which don't need
These seem to help, but I'm less familiar with bootstrap3 |
Moving the alert div inside the for loop would mean that if multiple errors are present, each field with errors will have its own separate alert with a list of errors, which looks strange and doesn't seem to line up well with the documented use:
updated example: Also, yeah I was a little hesitant about just adding django-crispy-forms/crispy_forms/layout.py Lines 315 to 318 in 77f4ea7
Might be worth adding a break to get out of that loop once the error class is added |
I noticed that when using the 'bootstrap3' template pack, the MultiField layout object shows the alert box for errors regardless of whether there actually are any. Based on the 'layouts/multifield.html' template, it seems the only prerequisite for showing the alert is that "form_show_errors" is enabled.
This was just a quick patch to solve my problem without disabling form errors entirely so I'm sure it'll be worth another look-over before marking for review.