{% extends 'tom_common/base.html' %}
{% load bootstrap4 %}
{% block title %}New Target{% endblock %}
{% block content %}
{% if not object %}
  <h3>Create a Target</h3>
  <ul class="nav nav-tabs">
    {% for k, v in type_choices %}
      <li class="nav-item">
        <a class="nav-link {% if form.type.initial == k %} active {% endif %}" href="{% url 'targets:create' %}?type={{ k }}">{{ v  }}</a>
      </li>
    {% endfor %}
{% else %}
<h3> Update {{ object.name }}</h3>

{% endif %}
</ul>
{% if not object %}
  <form method="post" class="form">
{% else %}
  <form method="post" class="form">
{% endif %}
{% csrf_token %}
{% bootstrap_form form %}
{% bootstrap_formset names_form %}
<h3>Tags</h3>
{% bootstrap_formset extra_form %}
{% buttons %}
  {% if not object %}
  <button type="submit" formaction="{% url 'targets:create' %}"class="btn btn-primary">Submit</button>
  {% else %}
  <button type="submit" formaction="{% url 'targets:update' pk=object.id %}"class="btn btn-primary">Save</button>
  <a href="{% url 'targets:detail' pk=object.id %}" class="btn btn-primary" title="Back">Back</a>
  {% endif %}
{% endbuttons %}
</form>
{% endblock %}
