Browse code

Make it compatible with latest Contao versions 4.7 and 4.8

Benjamin Roth authored on07/10/2019 12:16:55
Showing2 changed files
... ...
@@ -11,8 +11,8 @@
11 11
     }
12 12
   ],
13 13
   "require":{
14
-    "php": "^5.6 || ^7.0",
15
-    "contao/core-bundle": "^4.4"
14
+    "php": "^7.1",
15
+    "contao/core-bundle": "^4.7"
16 16
   },
17 17
   "conflict": {
18 18
     "contao/core": "*",
... ...
@@ -14,6 +14,7 @@
14 14
 <?php $this->block('field'); ?>
15 15
 <input type="text" name="<?= $this->name ?>" id="ctrl_<?= $this->id ?>" class="captcha mandatory<?php if ($this->class) echo ' ' . $this->class; ?>" value="" aria-describedby="captcha_text_<?= $this->id ?>"<?= $this->getAttributes() ?>>
16 16
 <span id="captcha_text_<?= $this->id ?>" class="captcha_text<?php if ($this->class) echo ' ' . $this->class; ?>"><?= $this->getQuestion() ?></span>
17
+<input type="hidden" name="<?= $this->name ?>_hash" value="<?= $this->getHash() ?>">
17 18
 
18 19
 <?php if (!$this->hasErrors()): ?>
19 20
   <div style="display:none">
... ...
@@ -21,8 +22,15 @@
21 22
     <input type="text" name="<?= $this->name ?>_name" id="ctrl_<?= $this->id ?>_hp" value="">
22 23
   </div>
23 24
   <script>
24
-    document.getElementById('ctrl_<?= $this->id ?>').parentNode.style.display = 'none';
25
-    document.getElementById('ctrl_<?= $this->id ?>').value = '<?= $this->getSum() ?>';
25
+    var e = document.getElementById('ctrl_<?= $this->id ?>'),
26
+      p = e.parentNode, f = p.parentNode;
27
+
28
+    if ('fieldset' === f.nodeName.toLowerCase() && 1 === f.children.length) {
29
+      p = f;
30
+    }
31
+
32
+    p.style.display = 'none';
33
+    e.value = '<?= $this->getSum() ?>';
26 34
   </script>
27 35
 <?php endif ?>
28 36