From a8cc2a85fca33394227bc11fd0db98faf3f1e019 Mon Sep 17 00:00:00 2001
From: Thorge Petersen <petersen@rz.uni-kiel.de>
Date: Mon, 20 Nov 2023 10:37:49 +0100
Subject: [PATCH] Worked on key generation for organization extras

---
 .../templates/organization/snippets/organization_form.html     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ckanext/odsh/templates/organization/snippets/organization_form.html b/ckanext/odsh/templates/organization/snippets/organization_form.html
index 9af3071d..77797c54 100644
--- a/ckanext/odsh/templates/organization/snippets/organization_form.html
+++ b/ckanext/odsh/templates/organization/snippets/organization_form.html
@@ -63,11 +63,12 @@
   
     {# Add a max of 3 empty columns #}
     {% set total_extras = data.extras|count %}
+    {% if total_extras <= (custom_extras|count) %}{% set total_extras = (custom_extras|count) %}{% endif %}
     {% set empty_extras = (limit or 3) - total_extras %}
     {% if empty_extras <= 0 %}{% set empty_extras = 1 %}{% endif %}
   
     {% for extra in range(total_extras, total_extras + empty_extras) %}
-      {% set index = loop.index0 + (data.extras|count) + (custom_extras|count) %}
+      {% set index = loop.index0 + total_extras %}
       {% set prefix = 'extras__%d__' % index %}
       {{ form.custom(
         names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'),
-- 
GitLab