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

{% block form %}
    <div class="field-group">
        <h4>Service</h4>
        {% if obj.device %}
            <div class="form-floating mb-3">
                <input class="form-control" value="{{ obj.device }}" disabled />
                <label class="form-label">Device</label>
            </div>
        {% else %}
            <div class="form-floating mb-3">
                <input class="form-control" value="{{ obj.virtual_machine }}" disabled />
                <label class="form-label">Virtual Machine</label>
            </div>
        {% endif %}
        {% render_field form.name %}
        <div class="mb-3">
            <label class="form-label">Port(s)</label>
            <div class="row">
                <div class="col-3">
                    {{ form.protocol }}
                </div>
                <div class="col-9 font-monospace">
                    {{ form.ports }}
                </div>
                <div class="form-text">{{ form.ports.help_text }}</div>
            </div>
        </div>
        
        {% render_field form.ipaddresses %}
        {% render_field form.description %}
        {% render_field form.tags %}
    </div>
    {% if form.custom_fields %}
        <div class="card">
            <h5 class="card-header">Custom Fields</h5>
            <div class="card-body">
                {% render_custom_fields form %}
            </div>
        </div>
    {% endif %}
{% endblock %}
