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

{% block form %}
  <div class="field-group my-5">
    <div class="row mb-2">
      <h5 class="offset-sm-3">Service</h5>
    </div>
    {% if obj.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="{{ obj.device }}" disabled />
            </div>
        </div>
    {% else %}
        <div class="row mb-3">
            <label class="col-sm-3 col-form-label text-lg-end">Virtual Machine</label>
            <div class="col">
                <input class="form-control" value="{{ obj.virtual_machine }}" disabled />
            </div>
        </div>
    {% endif %}
    {% render_field form.name %}
    <div class="row">
        <label class="col-sm-3 col-form-label text-lg-end">Port(s)</label>
        <div class="col-3">
            {{ form.protocol }}
        </div>
        <div class="col-6">
            {{ form.ports }}
        </div>
    </div>
    <div class="row mb-3">
        <div class="col-3"></div>
        <div class="col-9">
            <span class="form-text">{{ form.ports.help_text }}</span>
        </div>
    </div>
    {% render_field form.ipaddresses %}
    {% render_field form.description %}
    {% render_field form.tags %}
  </div>

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