Commit 841bceb7 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

use in-house css class .form-control-placeholder

parent 3c6e7430
......@@ -19,7 +19,7 @@ class IdForm(ModelForm):
fields = ['source','id_source']
widgets = {
'source' : forms.RadioSelect,
'id_source': forms.TextInput(attrs={'class': 'form-control'}),
'id_source': forms.TextInput(attrs={'placeholder': 'ID'}),
}
""" Step 2 : BibliographyForm """
......
......@@ -1368,6 +1368,10 @@ Description: IPPI-DB Theme
opacity: 0.5;
}
.form-control.is-invalid + .form-control-placeholder {
color: #dc3545;
}
.form-control:focus + .form-control-placeholder,
.form-control:valid + .form-control-placeholder {
font-size: 75%;
......
......@@ -46,7 +46,6 @@
</div>
<div class="input_field form-group">
{{ wizard.form.id_source|bootstrap}}
<label class="form-control-placeholder">ID</label>
</div>
</div>
{% endif %}
......
......@@ -19,12 +19,19 @@ def url_replace(request, field, value):
def bootstrap(object):
if isinstance(object, BoundField):
field = object
attrs = {"class": "form-control" + (" is-invalid" if field.errors else "")}
try:
placeholder = field.field.widget.attrs.pop("placeholder")
except KeyError:
placeholder = None
ret = []
ret.append(field.as_widget(attrs=attrs))
if placeholder:
ret.append("""<label class="form-control-placeholder">%s</label>""" % placeholder)
if field.errors:
ret = []
ret.append(field.as_widget(attrs={"class": "form-control is-invalid"}))
for e in field.errors:
ret.append("""<div class="invalid-feedback">%s</div>""" % e)
return mark_safe("".join(ret))
return mark_safe("".join(ret))
else:
logger.error("Can't bootstrapize object of class %s" % str(type(object)))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment