-
Notifications
You must be signed in to change notification settings - Fork 88
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
success_css_class
on bootstrap_field
takes no effect
#302
Comments
I'm experiencing the same problem. From reading the docs, it seems that success_css_class has been changed between v4 and v5. Previously, if it was empty, no class was applied. However, now it functions as "extra" CSS classes to be added on top of The old behavior was much more flexible, as we usually only want the error class applied and not a success class. The success class is effectively always applied, even on empty forms when they are rendered for the first time, which looks quite odd. |
Having the same issue. Any workarounds known yet? |
I've had a look into this and it appears the defaults for I've not tested this, but you should be able to override the from django_bootstrap5.renderers import FieldRenderer
class CustomFieldRenderer(FieldRenderer):
def get_server_side_validation_classes(self):
"""Return CSS classes for server-side validation."""
if self.field_errors:
return self.error_css_class
elif self.field.form.is_bound:
return self.success_css_class
return "" Also add to your settings roughly this BOOTSTRAP5 = {
'field_renderers': {
'default': 'SOME_PATH.CustomFieldRenderer',
},
} I'm doing something similar to prevent the setting of |
@tom-price, Thanks! This worked out-of-the-box and I'll use it until proper fix is available. |
@tom-price Thanks a lot for a great solution! |
I've noticed that overriding |
You are a savior! great workaround! |
@tom-price Do you mind crafting a PR for this? |
@tom-price is there any update on this issue? |
Code
![image](https://user-images.githubusercontent.com/2231969/163955295-89d02516-f0d5-43ff-9b01-2e56460cba88.png)
Result
![image](https://user-images.githubusercontent.com/2231969/163955400-f2bc403b-83b3-4ba3-84ef-a2cd7b29fddc.png)
The text was updated successfully, but these errors were encountered: