{% load crispy_forms_field %} {% comment %} Override of crispy-bootstrap5's field_file.html that supports PersistentFileWidget. When the widget context contains ``has_file`` (set by PersistentFileWidget.get_context), the persistent-file UI is rendered. Otherwise, the standard crispy file-input markup is used. {% endcomment %} {% for widget in field.subwidgets %} {% if widget.data.has_file %} {# --- PersistentFileWidget: uploaded file with Replace / Remove --- #} {# The wrapper carries is-invalid for the same reason as the plain branch #} {# below: Bootstrap only unhides .invalid-feedback next to an .is-invalid #} {# sibling, and this branch has no visible input to put the class on — so #} {# a rejected replacement file would fail silently. #} {% include "conjunto/forms/_persistent_file.html" with widget=widget.data %} {% include "bootstrap5/layout/help_text_and_errors.html" %} {% else %} {# --- Standard ClearableFileInput / FileInput --- #} {% if widget.data.is_initial %}
{{ widget.data.initial_text }}
{{ field.value.name }} {% if not widget.data.required %} {% endif %}
{% endif %} {% include 'bootstrap5/layout/help_text_and_errors.html' %} {% endif %} {% endfor %}