<div xmlns="http://www.w3.org/1999/xhtml"
     xmlns:py="http://genshi.edgewall.org/"
     xmlns:xi="http://www.w3.org/2001/XInclude"
     class="$container_cls">
  <py:with vars="ctx=widget.context_for(selector)">
    <py:if test="selector.show_label"><label for="$ctx.id">$selector.label</label><br/></py:if>
    <py:if test="ctx.errors and selector.show_errors"><span class="$error_class">$ctx.errors</span><br/></py:if>
    ${selector.display(css_class=selector_cls, **ctx)}
  </py:with>
  <div py:for="name, field in states.iteritems()"
       py:with="ctx=widget.context_for(field)"
       class="$field_cls"
       data-name="$name">
    <py:if test="field.show_label"><label for="$ctx.name">$field.label</label><br/></py:if>
    <py:if test="ctx.errors and field.show_errors"><span class="$error_class">$ctx.errors</span><br/></py:if>
    ${field.display(**ctx)}
  </div>
</div>
