Hallo
Kleine Frage an die Community: Ich möchte zwei Registrationsformulare (eines für Privatpersonen und eines für Firmen) auf der selben Seite platzieren. Mittels Select-Abfrage wird via Javascript entweder das eine oder andere eingeblendet. Das alles funktioniert soweit prima.
Was mich etwas verunsichert, ist das Captcha-Feld mit der Honeypot-Funktionalität. Und zwar wird ja bei beiden Registrationsfelder jeweils unterhalb des Captcha-Feldes folgendes im Quellcode (Bsp. Formular 2) eingetragen:
HTML-Code:
<div style="display:none">
<label for="ctrl_registration_hp">Do not fill in this field</label>
<input type="text" name="c812e1461ddc8e7bc4e3a9702cc0f87bb_name" id="ctrl_registration_hp" value="">
</div>
<script>document.getElementById('ctrl_registration').parentNode.style.display='none';document.getElementById('ctrl_registration').value='9'</script>
Im Template ist es wie folgt:
PHP-Code:
<?php if (!$this->hasErrors()): ?>
<div style="display:none">
<label for="ctrl_<?= $this->id ?>_hp">Do not fill in this field</label>
<input type="text" name="<?= $this->name ?>_name" id="ctrl_<?= $this->id ?>_hp" value="">
</div>
<script>
document.getElementById('ctrl_<?= $this->id ?>').parentNode.style.display = 'none';
document.getElementById('ctrl_<?= $this->id ?>').value = '<?= $this->getSum() ?>';
</script>
<?php endif ?>
Da es nun zwei Registrationsformulare sind, wird ja nur die erste gefundene ID angesteuert.
Ein weiteres Problem ist, dass aus Layoutgründen über das p.error und input ein DIV legen möchte.
PHP-Code:
--> <div class="col-xs-12 col-md-8">
<?php if ($this->hasErrors()): ?>
<p class="error"><?= $this->getErrorAsString() ?></p>
<?php endif; ?>
<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() ?>>
<span id="captcha_text_<?= $this->id ?>" class="captcha_text<?php if ($this->class) echo ' ' . $this->class; ?>"><?= $this->getQuestion() ?></span>
--> </div>
Durch das JavaScript wird dann dieses DIV (da neu parentNode von #ctrl_registration ausgeblendet, nicht aber auch das dazügehörende Label.
Grundsätzlich kann ich wohl alles schon anpassen (z.B. individuelle IDs), weiss aber nicht, ob ich dadurch die Captcha-Funktion ausheble.
Vielleicht kann mir da jemand eine Empfehlung abgeben, wie ich beide Probleme korrekt umgehen kann, ohne dass ich was kaputt mache.
Lesezeichen