forked from tzangms/django-bootstrap-form
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request tzangms#9 from loitran/master
Single form field outputting
- Loading branch information
Showing
4 changed files
with
49 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,5 @@ Usage | |
{% load bootstrap %} | ||
|
||
{{ form|bootstrap }} | ||
|
||
{{ form.<field name>|bootstrap }} - To output individual fields |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{% load bootstrap %} | ||
<div class="control-group{% if field.errors %} error{% endif %}"> | ||
{% if field|is_checkbox %} | ||
<div class="controls"> | ||
<label class="checkbox"> | ||
{{ field }} <span>{{ field.label }}</span> | ||
</label> | ||
|
||
{% for error in field.errors %} | ||
<span class="help-inline">{{ error }}</span> | ||
{% endfor %} | ||
|
||
{% if field.help_text %} | ||
<p class="help-block"> | ||
{{ field.help_text }} | ||
</p> | ||
{% endif %} | ||
</div> | ||
{% else %} | ||
<div class="control-label">{{ field.label }}</div> | ||
|
||
<div class="controls"> | ||
{{ field }} | ||
|
||
{% for error in field.errors %} | ||
<span class="help-inline">{{ error }}</span> | ||
{% endfor %} | ||
|
||
{% if field.help_text %} | ||
<p class="help-block"> | ||
{{ field.help_text }} | ||
</p> | ||
{% endif %} | ||
|
||
</div> | ||
{% endif %} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,10 @@ | ||
{% load bootstrap %} | ||
|
||
{{ form.non_field_errors }} | ||
|
||
{% for field in form.hidden_fields %} | ||
{{ field }} | ||
{% endfor %} | ||
|
||
{% for field in form.visible_fields %} | ||
<div class="control-group{% if field.errors %} error{% endif %}"> | ||
{% if field|is_checkbox %} | ||
<div class="controls"> | ||
<label class="checkbox"> | ||
{{ field }} <span>{{ field.label }}</span> | ||
</label> | ||
|
||
{% for error in field.errors %} | ||
<span class="help-inline">{{ error }}</span> | ||
{% endfor %} | ||
|
||
{% if field.help_text %} | ||
<p class="help-block"> | ||
{{ field.help_text }} | ||
</p> | ||
{% endif %} | ||
</div> | ||
{% else %} | ||
<div class="control-label">{{ field.label }}</div> | ||
|
||
<div class="controls"> | ||
{{ field }} | ||
|
||
{% for error in field.errors %} | ||
<span class="help-inline">{{ error }}</span> | ||
{% endfor %} | ||
|
||
{% if field.help_text %} | ||
<p class="help-block"> | ||
{{ field.help_text }} | ||
</p> | ||
{% endif %} | ||
|
||
</div> | ||
{% endif %} | ||
</div> | ||
{% include 'bootstrapform/field.html' %} | ||
{% endfor %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters