{% extends "telemeta/resource_detail.html" %}
{% load i18n %}
{% load telemeta_tags %}

{% block extra_javascript %}{% endblock %}

{% block title %}
<img src="{{ STATIC_URL }}telemeta/images/{{ type }}.png" style="vertical-align:middle" /> {{ type|capitalize }} : {{ resource }}
{% endblock %}

{% block title_buttons %}
 <a href="{% url "telemeta-resource-detail" type resource.public_id %}" class="component_icon button icon_cancel">{% trans "Cancel" %}</a>
 <a href="#" class="component_icon button icon_save" onclick="document.getElementById('_editMediaRelatedFileForm').submit(); return false;">{% trans "Save" %}</a>
{% endblock %}

{% block content %}
  {% block infos %}
    <div class="infos">
     <form enctype="multipart/form-data" method="post" id="_editMediaRelatedFileForm" action="">{% csrf_token %}

    {{ formset.management_form }}
    {% for form in formset.forms %}
      <table class="related_media">
        <tr><td><b>{% trans "Media" %} :</b><td></td></tr>
        {% for field in form %}
        <tr><td class="error">{{ field.errors }}</td></tr>
        <tr>
            {% if "resource" in field.html_name or "id" in field.html_name or "mime_type" in field.html_name %}
                <td>{{ field.label_tag.as_hidden }}</td><td>{{ field.as_hidden }}</td>
            {% else %}
                <td>{{ field.label_tag }}: </td><td>{{ field }}</td>
            {% endif %}
        </tr>
        {% endfor %}
       </table>
       <br />
    {% endfor %}
      <div align="center">
        <a href="{% url "telemeta-resource-detail" type resource.public_id %}"
           class="component_icon button icon_cancel">{% trans "Cancel" %}</a>
        <a href="#" class="component_icon button icon_save" onclick="document.getElementById('_editMediaRelatedFileForm').submit(); return false;">{% trans "Save" %}</a>
       </div>
     </form>
    </div>
  {% endblock infos %}
{% endblock content %}
