Answer the question
In order to leave comments, you need to log in
How to get the captcha image from the form element separately from the input in zf2?
Good day.
When developing the site, the following problem arose:
when using the "captcha" form element (standard captcha from zf2)
<div><?php
echo $this->formElement($registerForm->get('captcha'));
?></div>
<div>
<img width="120" height="50" alt="" src="/images/captcha/054fbf1c546eb312aa0dc72980e573b8.png">
<input name="captcha[id]" type="hidden" value="054fbf1c546eb312aa0dc72980e573b8">
<input name="captcha[input]" type="text">
</div>
<div>
<img width="120" height="50" alt="" src="/images/captcha/054fbf1c546eb312aa0dc72980e573b8.png">
</div>
<div>
<input name="captcha[id]" type="hidden" value="054fbf1c546eb312aa0dc72980e573b8">
<input name="captcha[input]" type="text">
</div>
$this->formElement($registerForm->get('captcha'));
Answer the question
In order to leave comments, you need to log in
Pay attention to the separator option , which is in the base class of all captcha view helpers. You need to give it a value '</div><div>'
.
<div>
<?php
$captcha = $registerForm->get('captcha');
echo $this->formCaptchaImage()->setSeparator('</div><div>')->render($captcha);
?>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question