Browse code

Captcha widget template adjustments for Contao ~4.4.x

Benjamin Roth authored on07/11/2018 12:37:55
Showing1 changed files
... ...
@@ -1,25 +1,29 @@
1 1
 <?php $this->extend('form_row'); ?>
2 2
 
3 3
 <?php $this->block('label'); ?>
4
-  <?php if ($this->hasErrors()): ?>
5
-    <span class="errortip" title="<?= htmlspecialchars($this->getErrorsAsString()); ?>" data-tooltip="position: top; offsetY: 10; theme: tooltipster-error; contentAsHTML: true;">?</span>
6
-  <?php endif; ?>
7
-
8
-  <?php if ($this->label): ?>
9
-    <label for="ctrl_<?= $this->id; ?>"<?php if ($this->class): ?> class="<?php echo $this->class; ?>"<?php endif; ?>>
10
-      <?php if ($this->mandatory): ?>
11
-        <span class="invisible"><?= $this->mandatoryField; ?></span> <?php echo $this->getQuestion(); ?><span class="mandatory">*</span>
12
-      <?php else: ?>
13
-        <?= $this->getQuestion(); ?>
14
-      <?php endif; ?>
15
-    </label>
16
-  <?php endif; ?>
4
+<?php if ($this->hasErrors()): ?>
5
+  <span class="errortip" title="<?= htmlspecialchars($this->getErrorsAsString()); ?>" data-tooltip="position: top; offsetY: 10; theme: tooltipster-error; contentAsHTML: true;">?</span>
6
+<?php endif; ?>
7
+<?php if ($this->label): ?>
8
+  <label for="ctrl_<?= $this->id ?>"<?php if ($this->class): ?> class="<?= $this->class ?>"<?php endif; ?>>
9
+    <span class="invisible"><?= $this->mandatoryField ?> </span><?= $this->label ?><span class="mandatory">*</span>
10
+  </label>
11
+<?php endif; ?>
17 12
 <?php $this->endblock(); ?>
18 13
 
19 14
 <?php $this->block('field'); ?>
20
-  <input type="text" name="<?= $this->name; ?>" id="ctrl_<?php echo $this->id; ?>" class="captcha mandatory<?php if ($this->class) echo ' ' . $this->class; ?>" value=""<?php echo $this->getAttributes(); ?>>
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
+<span id="captcha_text_<?= $this->id ?>" class="captcha_text<?php if ($this->class) echo ' ' . $this->class; ?>"><?= $this->getQuestion() ?></span>
17
+
18
+<?php if (!$this->hasErrors()): ?>
19
+  <div style="display:none">
20
+    <label for="ctrl_<?= $this->id ?>_hp">Do not fill in this field</label>
21
+    <input type="text" name="<?= $this->name ?>_name" id="ctrl_<?= $this->id ?>_hp" value="">
22
+  </div>
23
+  <script>
24
+    document.getElementById('ctrl_<?= $this->id ?>').parentNode.style.display = 'none';
25
+    document.getElementById('ctrl_<?= $this->id ?>').value = '<?= $this->getSum() ?>';
26
+  </script>
27
+<?php endif ?>
21 28
 
22
-  <?php if ($this->addSubmit): ?>
23
-    <input type="submit" id="ctrl_<?= $this->id; ?>_submit" class="submit" value="<?php echo $this->slabel; ?>">
24
-  <?php endif; ?>
25 29
 <?php $this->endblock(); ?>