{% load static %}

<!-- 
  Début de piste pour la génération de du name en tagID de manière automatique

  document.addEventListener('DOMContentLoaded', () => {
  const nameInput = document.getElementById('id_name');
  const tagInput  = document.getElementById('id_cf_TagID'); // adapte si ton slug diffère

  if (!nameInput || !tagInput) return;
  nameInput.readOnly = true;
  nameInput.setAttribute('autocomplete', 'off');
  nameInput.value = (tagInput.value || '').trim();
  tagInput.addEventListener('input', () => {
    nameInput.value = tagInput.value.trim();
  });
}); -->

 <div class="nbx-inline-field" data-cf-id="{{ widget.attrs.data_cf_id }}">
  <input type="text"
         class="form-control"
         name="{{ widget.name }}"
         value="{{ widget.value }}"
         {% include "django/forms/widgets/attrs.html" %} />
         <!-- with attrs=widget.attrs -->

  <button type="button" class="btn btn-primary nbx-wide-btn" onclick="netbox_tag_id_generate(event.target.parentElement);">
    Générer
  </button>

  <button type="button" class="btn btn-cyan nbx-wide-btn" onclick="netbox_tag_id_print(event.target.parentElement);">
    <i class="mdi mdi-printer"></i>
    Imprimer
  </button>
</div>

