{% load form_block %}

{% with styles=form_block.form.label_class.LabelStyle %}
{% with label=labels|get_by_style:styles.VERTICAL %}
{% with hlabel=labels|get_by_style:styles.HORIZONTAL %}
{% with wlabel=labels|get_by_style:styles.WIDGET %}
{% if label %}
<div class="mdc-layout-grid__inner">
  {% if not hlabel and not wlabel %}
    {% include "./label_vertical.html" with for_field=field %}
  {% else %}
    {% include "./label_vertical.html" %}
  {% endif %}
</div>
{% endif %}

<div class="mdc-layout-grid__inner">

{% with s=hlabel|yesno:"-2,0" sp=form_block.span %}
{% if hlabel %}
<div class="rp-horizontal-label-cell
            mdc-layout-grid__cell--span-{% if sp == 1 %}1{% else %}2{% endif %}
            mdc-layout-grid__cell--span-2-tablet
            mdc-layout-grid__cell--span-2-desktop">
  <label {% if not wlabel %}for="{{ field.id_for_label }}"{% endif %}>
    {{ hlabel.display_inline }}
  </label>
</div>
{% endif %}

{% with types=form_block.InputType %}
{% with tsp=form_block.tablet_span dsp=form_block.desktop_span %}
<div class="rp-layout-cell rp-layout-cell-{{ form_block.type }}
            mdc-layout-grid__cell
mdc-layout-grid__cell--span-{% if sp < 4 %}{{ sp }}{% else %}{{ sp|add:s }}{% endif %}
mdc-layout-grid__cell--span-{% if sp < 4 %}{{ tsp }}{% else %}{{ tsp|add:s }}{% endif %}-tablet
mdc-layout-grid__cell--span-{% if sp < 4 %}{{ dsp }}{% else %}{{ dsp|add:s }}{% endif %}-desktop
">
{% endwith %}

{% if form_block.type == types.TEXT or form_block.type == types.NUMERIC %}
  {% include "./custom_block_text.html" %}
  
{% elif form_block.type == types.CHOICE %}
  {% include "./custom_block_choice.html" %}
    
{% elif form_block.type == types.BOOLEAN %}
  {% include "./custom_block_boolean.html" %}
  
{% endif %}
{% endwith %}

{% endwith %}

{% endwith %}
{% endwith %}
{% endwith %}
{% endwith %}
</div>
</div>
