{% load i18n %}
{% if not field.is_hidden %}
<tr id="form-{{field.name}}">
    <td style="text-align:right;">
    {% if field.errors %}<div class="ym-fbox-text ym-error"><span class="ym-message">{% endif %}
    <label for="{{field.auto_id}}">
        {% trans field.label %}
    </label>
    {% if not field.field.required %}<span style="font-size:90%;">— <em>{% trans "Optional" %}</em></span>{% endif %}
    {% if field.errors %}</span></div>{% endif %}
    </td>
    <td>
        <div class="{{css_class}} {% if field.errors %}ym-error{% endif %}">
        {{ field }}
        </div>

        {% if field.errors %}
            <div class="ym-fbox-text ym-error">
                {% for error in field.errors %}
                    <p class="ym-message">{% trans error %}</p>
                {% endfor %}
            </div>
        {% endif %}

        {% if field.help_text %}<p class="dimmed">{% trans field.help_text %}</p>{% endif %}
    </td>
</tr>
{% else %}
    {#                                        #}
    {#  TODO: the resulting HTML is not valid #}
    {#  and all the form rendering functions  #}
    {#  should be made more flexible anyway   #}
    {{field}}
{% endif %}