Skip to content
Snippets Groups Projects
Commit 59b18141 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Calculate length of custom dataset extras instead using harcoded value

parent 5c4b15de
No related branches found
No related tags found
No related merge requests found
...@@ -47,8 +47,9 @@ ...@@ -47,8 +47,9 @@
{{ form.input_address('gnd','GND URI', value=extras.gnd, index=6, placeholder='https://d-nb.info/gnd/1136109587', type='text', attrs={}) }} {{ form.input_address('gnd','GND URI', value=extras.gnd, index=6, placeholder='https://d-nb.info/gnd/1136109587', type='text', attrs={}) }}
{% for extra in data.extras %} {% for extra in data.extras %}
{% if extra.key not in ['person','street','location','telephone','mail','web','gnd'] %} {% set custom_extras = ['person','street','location','telephone','mail','web','gnd'] %}
{% set prefix = 'extras__%d__' % (loop.index0 + 7) %} {% if extra.key not in custom_extras %}
{% set prefix = 'extras__%d__' % (loop.index0 + (custom_extras|count)) %}
{{ form.custom( {{ form.custom(
names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'), names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'),
id='field-extras-%d' % loop.index, id='field-extras-%d' % loop.index,
...@@ -65,7 +66,7 @@ ...@@ -65,7 +66,7 @@
{% if empty_extras <= 0 %}{% set empty_extras = 1 %}{% endif %} {% if empty_extras <= 0 %}{% set empty_extras = 1 %}{% endif %}
{% for extra in range(total_extras, total_extras + empty_extras) %} {% for extra in range(total_extras, total_extras + empty_extras) %}
{% set index = loop.index0 + (data.extras|count) + 7 %} {% set index = loop.index0 + (data.extras|count) + (custom_extras|count) %}
{% set prefix = 'extras__%d__' % index %} {% set prefix = 'extras__%d__' % index %}
{{ form.custom( {{ form.custom(
names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'), names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment