From 4aa9a9011a37653346ce8c222d1f651492ba7d14 Mon Sep 17 00:00:00 2001
From: Carsten  Rose <carsten.rose@math.uzh.ch>
Date: Thu, 23 Mar 2017 12:42:12 +0100
Subject: [PATCH] AbstractBuildForm.php: #3399 templateGroup: Hide 'add' if
 limit is reached.

---
 extension/qfq/qfq/AbstractBuildForm.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php
index a0421a7fc..2b82b9d79 100644
--- a/extension/qfq/qfq/AbstractBuildForm.php
+++ b/extension/qfq/qfq/AbstractBuildForm.php
@@ -2875,6 +2875,7 @@ abstract class AbstractBuildForm {
         // save parent processed FE's
         $feSpecNativeSave = $this->feSpecNative;
 
+        $addButtonId = 'add_button_' . $formElement[FE_ID];
         $qfqFieldsName = 'qfq_fields_' . $formElement[FE_ID]; // ='qfq-fields'
         $templateName = 'template_' . $formElement[FE_ID]; // ='template'
         $targetName = 'target_' . $formElement[FE_ID]; // ='template'
@@ -2894,7 +2895,7 @@ abstract class AbstractBuildForm {
 EOT;
 
         $htmlAdd = <<<EOT
-<button type="button" class="$addClass" onclick="QfqNS.addFields('#$templateName', '#$targetName', $max)">$addText</button>
+<button type="button" id="$addButtonId" class="$addClass" onclick="QfqNS.addFields('#$templateName', '#$targetName', $max)">$addText</button>
 EOT;
 
         $htmlDelete = <<<EOT
@@ -2920,6 +2921,7 @@ EOT;
         $attribute = Support::doAttribute('class', $qfqFieldsName);
         $attribute .= Support::doAttribute('id', $targetName);
         $attribute .= Support::doAttribute('data-qfq-line-template', '#' . $templateName);
+        $attribute .= Support::doAttribute('data-qfq-line-add-button', '#' . $addButtonId);
 
         // Element where the effective FormElements will be copied to. The BS 'col-md-* Classes are inside the template, not here. This here should be pure data without wrapping.
         $html = Support::wrapTag("<div $attribute>", $html, false);
-- 
GitLab