Skip to content

Instantly share code, notes, and snippets.

@skyler
Created August 13, 2012 14:09
Show Gist options
  • Save skyler/3341085 to your computer and use it in GitHub Desktop.
Save skyler/3341085 to your computer and use it in GitHub Desktop.
{% macro input_with_errors(field) -%}
<div class="control-group{% if field.errors %} error{% endif %}">
<label class="control-label" for="{{ field.id }}>{{ field.label }}</label>
<div class="controls">
<input type="text" class="input-large" id="{{ field.id }}" name="{{ field.name }}"{%if field.data %} value="{{ field.data|e }}"{% endif %}>
{%- if field.errors %}<span class="help-inline">{{ field.errors|join(' ') }}</span>{% endif %}
</div>
</div>
{%- endmacro %}
{%- macro select_with_errors(field, options) -%}
<div class="control-group{% if field.errors %} error{% endif %}">
<label class="control-label" for="{{ field.id }}">{{ field.label }}</label>
<div class="controls">
<select id="{{ field.id }}" name="{{ field.name }}">
{%- for option in options %}
<option value="{{ option }}">{{ option }}</option>
{%- endfor %}
</select>
{% if field.errors %}<span class="help-inline">{{ field.errors|join(' ') }}</span>{% endif -%}
</div>
</div>
{%- endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment