{% macro hint(field) %}
  {%- if field.hint and not field.widget.renders_hint %}
    <span class="hint">{{ field.hint }}</span>
  {%- endif -%}
{% endmacro -%}

{% macro label(field) %}
  {%- if field.label %}
    <label for="{{ field.id }}">{{ field.label }}</label>
  {%- endif -%}
{% endmacro -%}

<table class="fieldset{% if widget.classname %} {{ widget.classname }} {% endif %}">
{%- for subfield in field.fields %}
  {%- set changed = field.form.changed_fields is defined and 
                    subfield.input_name in field.form.changed_fields %}
  {%- if subfield.readable %}
    {%- if subfield.error -%}
    <tr class="error-row">
      <td colspan="2">
        <span class="error">{{ subfield.error }}</span>
      </td>
    </tr>
    {%- endif -%}
    <tr class="form-row{% if loop.last %} last{% endif %}
              {%- if changed %} changed-after-publication{% endif %}"
      {%- if subfield.widget.render_type == 'hidden' %} style="display:none"{% endif %}>
    {%- if subfield.widget.render_type == 'checkbox' -%}
      <th></th>
      <td>
        {{- subfield.widget.render()|safe }}
        {{- label(subfield) -}}
        {{- hint(subfield) -}}
      </td>
    {%- elif subfield.widget.render_type == 'hidden' -%}
      <td colspan="2">{{ subfield.widget.render()|safe }}</td>
    {%- elif subfield.widget.render_type == 'full-width' -%}
      <td class="full-width" colspan="2">
        {{- label(subfield) -}}
        {{- subfield.widget.render()|safe -}}
        {{- hint(subfield) -}}
      </td>
    {%- else -%}
      <th>
        {{- label(subfield) -}}
      </th>
      <td>
        {{- subfield.widget.render()|safe -}}
        {{- hint(subfield) -}}
      </td>
    {%- endif -%}
    </tr>
  {%- endif -%}
{% endfor -%}
</table>
