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 %}
|
||||
|
||||
<div class="container-fluid">
|
||||
<form role="form" method="post">
|
||||
{% csrf_token %}
|
||||
{% for field in form %}
|
||||
<div class="form-group">
|
||||
<label for="id_{{ field.name }}">{{ field.label }}</label>
|
||||
<div class="d-none">{{ field|field_type }}</div>
|
||||
<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 %}
|
||||
{{ field|add_class:"form-control is-invalid" }}
|
||||
{{ field|add_class:'form-check-input is-invalid' }}
|
||||
{% 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 %}
|
||||
{% if field.help_text %}
|
||||
<p class="help-block"><small>{{ field.help_text }}</small></p>
|
||||
|
@ -20,3 +40,4 @@
|
|||
{% endfor %}
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
</div>
|
Loading…
Reference in New Issue