Created
February 19, 2012 22:13
-
-
Save xen/1866144 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(form, action=None, name="default") -%} | |
| {# XXX: Place for global form error. | |
| {% if form.errors %}...{% endif %} | |
| #} | |
| {% for name, field in form.form(name) %} | |
| {{ row(field, name, **kwargs) }} | |
| {% endfor %} | |
| <input type="hidden" value="1" name="form.submitted"> | |
| {% if action %} | |
| <div class="form-actions"> | |
| <button type="submit" class="btn btn-primary">{{ action }}</button> | |
| </div> | |
| {% endif %} | |
| {%- endmacro %} | |
| {%- macro row(field, name) %} | |
| <div class="control-group {% if field.errors %}error{% endif %}"> | |
| <label for="{{field.name}}">{{ field.label }}</label> | |
| <div class="controls"> | |
| <p>{{field | f(name=name)}}</p> | |
| {% if field.errors %}<span class="help-inline">{{ field.errors|join(', ') }}</span>{% endif %} | |
| {% if field.description %}<span class="help-block">{{ field.description }}</span>{% endif %} | |
| </div> | |
| </div> | |
| {%- endmacro %} | |
| {%- macro render_search(form, url, action="Найти") %} | |
| <div class="well"> | |
| <form action="{{ url }}" method="GET"> | |
| {% for field in form %} | |
| {{ row_search(field, **kwargs) }} | |
| <div class="pull-left"> </div> | |
| {% endfor %} | |
| <button class="btn btn-primary pull-right" type="submit" class="btn">{{ action }}</button> | |
| </form> | |
| </div> | |
| {%- endmacro %} | |
| {%- macro row_search(field) %} | |
| {{ field(class="pull-left", **kwargs)|safe }} | |
| {%- endmacro %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment