Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check to handle empty form attributes in general non-crispy template #3140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions python/nav/web/templates/custom_crispy_templates/_form_content.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
{# NB! This template can be used directly (without form template wrapper) for cases where form.helper.form_tag is set to False. #}
{% load forms %}

{% if form.attrs.method|lower == 'post' %}
{% csrf_token %}
{% endif %}
{% if form.attrs %}
{% if form.attrs.method|lower == 'post' %}
{% csrf_token %}
{% endif %}

{% include 'foundation-5/errors.html' %}
{% include 'foundation-5/errors.html' %}

{% block form_fields %}
{% if form.attrs.form_fields %}
{% include 'custom_crispy_templates/_form_fields.html' with fields=form.attrs.form_fields %}
{% else %}
{% for field in form %}
{% show_field field %}
{% endfor %}
{% endif %}
{% if form.attrs.submit_field %}
{% include 'custom_crispy_templates/submit_field.html' with input=form.attrs.submit_field %}
{% endif %}
{% endblock form_fields %}
{% block form_fields %}
{% if form.attrs.form_fields %}
{% include 'custom_crispy_templates/_form_fields.html' with fields=form.attrs.form_fields %}
{% else %}
{% for field in form %}
{% show_field field %}
{% endfor %}
{% endif %}
{% if form.attrs.submit_field %}
{% include 'custom_crispy_templates/submit_field.html' with input=form.attrs.submit_field %}
{% endif %}
{% endblock form_fields %}
{% else %}
{{ form }}
{% endif %}
Loading