Override the django-bootstrap3 default help-text-and-errors rendering
to separate the unrelated concepts - Legacy-Id: 11177
This commit is contained in:
parent
b83e0d2c78
commit
b599dca51d
|
@ -309,6 +309,12 @@ BOOTSTRAP3 = {
|
|||
|
||||
# Class to indicate error
|
||||
'form_error_class': 'bootstrap3-error',
|
||||
|
||||
'field_renderers': {
|
||||
'default': 'ietf.utils.bootstrap.SeparateErrorsFromHelpTextFieldRenderer',
|
||||
'inline': 'bootstrap3.renderers.InlineFieldRenderer',
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
INTERNAL_IPS = (
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
<div class='alert alert-warning'>
|
||||
{% for item in help_text_and_errors %} {{ item }}<br> {% endfor %}
|
||||
</div>
|
9
ietf/utils/bootstrap.py
Normal file
9
ietf/utils/bootstrap.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
import bootstrap3.renderers
|
||||
|
||||
class SeparateErrorsFromHelpTextFieldRenderer(bootstrap3.renderers.FieldRenderer):
|
||||
def append_to_field(self, html):
|
||||
if self.field_help:
|
||||
html += '<div class="help-block">{}</div>'.format(self.field_help)
|
||||
for e in self.field_errors:
|
||||
html += '<div class="alert alert-danger">{}</div>'.format(e)
|
||||
return html
|
Loading…
Reference in a new issue