Implement example Bootstrap 4 styled form in Baby Add form.

This commit is contained in:
Christopher Charbonneau Wells 2017-08-15 16:50:33 -04:00
parent 3d90a21144
commit 12e700eb74
1 changed files with 19 additions and 3 deletions

View File

@ -1,12 +1,28 @@
{% extends 'core/base.html' %} {% extends 'core/base.html' %}
{% load i18n widget_tweaks %}
{% block title %}Add a Baby{% endblock %} {% block title %}Add a Baby{% endblock %}
{% block content %} {% block content %}
<h1>Add a Baby</h1> <h1>Add a Baby</h1>
<form method="POST" class="post-form"> <form role="form" method="post">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {% for field in form %}
<button type="submit" class="save btn btn-default">Save</button> <div class="form-group">
<label for="id_{{ field.name }}">{{ field.label }}</label>
{% if field.errors %}
{{ field|attr:"class:form-control is-invalid" }}
{% else %}
{{ field|attr:"class:form-control" }}
{% endif %}
{% if field.help_text %}
<p class="help-block"><small>{{ field.help_text }}</small></p>
{% endif %}
{% if field.errors %}
<p class="invalid-feedback">{% for error in field.errors %}{{ error }}{% endfor %}</p>
{% endif %}
</div>
{% endfor %}
<button type="submit" class="btn btn-primary">{% trans "Submit" %}</button>
</form> </form>
{% endblock %} {% endblock %}