mapping_item.pt 2.58 KB
<block
  tal:define="error_class error_class|field.widget.error_class;
                 description description|field.description;
                 title title|field.title;
                 oid oid|field.oid;
                 hidden hidden|field.widget.hidden;
                 category category|field.widget.category;
                 structural hidden or category == 'structural';
                 required required|field.required;
                 css_class css_class|field.widget.css_class;"
  class="${field.error and 'has-error' or ''} ${field.widget.item_css_class or ''} ${field.default_item_css_class()} ${css_class}"
  title="${description}"
  id="item-${oid}"
  tal:omit-tag="structural"
  i18n:domain="deform"
>
  <span tal:condition="not field.children">
    <span tal:replace="structure field.serialize(cstruct).strip()" />

    <div
      tal:condition="field.error and not field.widget.hidden and not field.typ.__class__.__name__=='Mapping'"
      class="absolute inset-y-0 end-0 flex items-center pointer-events-none pe-3"
    >
      <i
        class="ti ti-alert-circle text-lg leading-tight font-medium text-error"
      ></i>
    </div>

    <p
      tal:define="errstr 'error-%s' % field.oid"
      tal:repeat="msg field.error.messages()"
      i18n:translate=""
      tal:attributes="id repeat.msg.index==0 and errstr or
     ('%s-%s' % (errstr, repeat.msg.index))"
      tal:condition="field.error and not field.widget.hidden and not field.typ.__class__.__name__=='Mapping'"
      class="text-sm text-error mt-2"
    >
      ${msg}
    </p>

    <p tal:condition="field.description and not field.widget.hidden">
      ${field.description}
    </p>
  </span>

  <span tal:condition="field.children">
    <div
      tal:define="input_prepend field.widget.input_prepend | None;
            input_append field.widget.input_append  | None"
      tal:omit-tag="not (input_prepend or input_append)"
    >
      <span tal:condition="input_prepend">${input_prepend}</span>
      <span tal:replace="structure field.serialize(cstruct).strip()" />
      <span tal:condition="input_append">${input_append}</span>
    </div>

    <p
      tal:define="errstr 'error-%s' % field.oid"
      tal:repeat="msg field.error.messages()"
      i18n:translate=""
      tal:attributes="id repeat.msg.index==0 and errstr or
                ('%s-%s' % (errstr, repeat.msg.index))"
      tal:condition="field.error and not field.widget.hidden and not field.typ.__class__.__name__=='Mapping'"
    >
      ${msg}
    </p>

    <p tal:condition="field.description and not field.widget.hidden">
      ${field.description}
    </p>
  </span>
</block>