Last active
March 1, 2018 22:09
-
-
Save teisman/5653607 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{% macro render(form) -%} | |
<fieldset> | |
{% for field in form %} | |
{% if field.type in ['CSRFTokenField', 'HiddenField'] %} | |
{{ field() }} | |
{% else %} | |
<div class="clearfix {% if field.errors %}error{% endif %}"> | |
{{ field.label }} | |
<div class="input"> | |
{% if field.name == "body" %} | |
{{ field(rows=10, cols=40) }} | |
{% else %} | |
{{ field() }} | |
{% endif %} | |
{% if field.errors or field.help_text %} | |
<span class="help-inline"> | |
{% if field.errors %} | |
{{ field.errors|join(' ') }} | |
{% else %} | |
{{ field.help_text }} | |
{% endif %} | |
</span> | |
{% endif %} | |
</div> | |
</div> | |
{% endif %} | |
{% endfor %} | |
</fieldset> | |
{% endmacro %} | |
This file contains hidden or 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
{% import '_forms.html' as forms %} | |
<!-- ... --> | |
{% block form %} | |
<section> | |
<h1>{{ action }} {{ data_type }}</h1> | |
<form action="{{ form_action }}" method="{{ method | d("POST") }}"> | |
{{ forms.render(form) }} | |
<input type="submit" value="Submit"> | |
</form> | |
</section> | |
{% endblock form %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment