mirror of https://github.com/snachodog/mybuddy.git
Add custom form field settings for boolean fields.
This commit is contained in:
parent
a89a237b5c
commit
33239a097b
|
@ -1,14 +1,34 @@
|
||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
<form role="form" method="post">
|
<form role="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% for field in form %}
|
{% for field in form %}
|
||||||
<div class="form-group">
|
<div class="d-none">{{ field|field_type }}</div>
|
||||||
<label for="id_{{ field.name }}">{{ field.label }}</label>
|
<div class="form-group row">
|
||||||
|
{% if field|field_type == 'booleanfield' %}
|
||||||
|
<div class="col-sm-1"> </div>
|
||||||
|
<div class="col-sm-11">
|
||||||
|
<div class="form-check">
|
||||||
|
<label for="id_{{ field.name }}" class="form-check-label">
|
||||||
{% if field.errors %}
|
{% if field.errors %}
|
||||||
{{ field|add_class:"form-control is-invalid" }}
|
{{ field|add_class:'form-check-input is-invalid' }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ field|add_class:"form-control" }}
|
{{ field|add_class:'form-check-input' }}
|
||||||
|
{% endif %}
|
||||||
|
{{ field.label }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<label for="id_{{ field.name }}" class="col-sm-1 col-form-label">{{ field.label }}</label>
|
||||||
|
<div class="col-sm-11">
|
||||||
|
{% if field.errors %}
|
||||||
|
{{ field|add_class:'form-control is-invalid' }}
|
||||||
|
{% else %}
|
||||||
|
{{ field|add_class:'form-control' }}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if field.help_text %}
|
{% if field.help_text %}
|
||||||
<p class="help-block"><small>{{ field.help_text }}</small></p>
|
<p class="help-block"><small>{{ field.help_text }}</small></p>
|
||||||
|
@ -20,3 +40,4 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
Loading…
Reference in New Issue