{% load crispy_forms_bulma_field %}

{% if field.is_hidden %}
  {{ field }}
{% else %}
  <div
    id="div_{{ field.auto_id }}"
    class="field{% if wrapper_class %} {{ wrapper_class }}{% endif %}"
  >
  
  {% spaceless %}
    {% if field.label and not field|is_radioselect and not field|is_checkbox %}
      {% if field|is_checkbox %}
        {% crispy_field field %}
      {% endif %}

      <label for="{{ field.id_for_label }}" class="label">
        {{ field.label|safe }}
        {% if field.field.required %}
          <span class="asterisk">*</span>
        {% endif %}
      </label>
    {% endif %}

    <div class="control">
      {% if field|is_select %}
        <div class="select">
          {% crispy_field field %}
        </div>

      {% elif field|is_radioselect %}
        {% include 'bulma/layout/radioselect.html' %}

      {% elif field|is_checkbox %}
        {% include 'bulma/layout/checkbox.html' %}

      {% elif not field|is_checkboxselectmultiple %}
        {% crispy_field field %}
      {% endif %}
    </div>

    {% if form_show_errors %}
      {% for error in field.errors %}
        <p id="error_{{ forloop.counter }}_{{ field.auto_id }}"
           class="help is-danger">
          {{ error }}
        </p>
      {% endfor %}
    {% endif %}

    {% if field.help_text %}
      <p id="hint_{{ field.auto_id }}" class="help">{{ field.help_text|safe }}</p>
    {% endif %}
  {% endspaceless %}
  </div>
{% endif %}
