{% extends 'generic/object_edit.html' %}
{% load form_helpers %}

{% block form %}
    {# Render hidden fields #}
    {% for field in form.hidden_fields %}
      {{ field }}
    {% endfor %}

    <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">Interface</h5>
        </div>
        {% if form.instance.device %}
            <div class="row mb-3">
                <label class="col-sm-3 col-form-label text-lg-end">Device</label>
                <div class="col">
                    <input class="form-control" value="{{ form.instance.device }}" disabled />
                </div>
            </div>
        {% endif %}
        {% render_field form.module %}
        {% render_field form.name %}
        {% render_field form.type %}
        {% render_field form.speed %}
        {% render_field form.duplex %}
        {% render_field form.label %}
        {% render_field form.description %}
        {% render_field form.tags %}
    </div>

    <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">Addressing</h5>
        </div>
        {% render_field form.vrf %}
        {% render_field form.mac_address %}
        {% render_field form.wwn %}
    </div>

    <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">Operation</h5>
        </div>
        {% render_field form.mtu %}
        {% render_field form.tx_power %}
        {% render_field form.enabled %}
        {% render_field form.mgmt_only %}
        {% render_field form.mark_connected %}
    </div>

    <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">Related Interfaces</h5>
        </div>
        {% render_field form.parent %}
        {% render_field form.bridge %}
        {% render_field form.lag %}
    </div>

    {% if form.instance.is_wireless %}
        <div class="field-group my-5">
            <div class="row mb-2">
              <h5 class="offset-sm-3">Wireless</h5>
            </div>
            {% render_field form.rf_role %}
            {% render_field form.rf_channel %}
            {% render_field form.rf_channel_frequency %}
            {% render_field form.rf_channel_width %}
            {% render_field form.wireless_lan_group %}
            {% render_field form.wireless_lans %}
        </div>
    {% endif %}

    <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">Power over Ethernet (PoE)</h5>
        </div>
        {% render_field form.poe_mode %}
        {% render_field form.poe_type %}
    </div>

    <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">802.1Q Switching</h5>
        </div>
        {% render_field form.mode %}
        {% render_field form.vlan_group %}
        {% render_field form.untagged_vlan %}
        {% render_field form.tagged_vlans %}
    </div>

    {% if form.custom_fields %}
      <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">Custom Fields</h5>
        </div>
        {% render_custom_fields form %}
      </div>
    {% endif %}
{% endblock %}
