[英]zend form captcha problem
I am using zend captcha in zend form. 我正在使用zend形式的zend验证码。 it's working properly, but when it creates then it generate this code:
它工作正常,但是在创建时会生成以下代码:
<img width="80" height="30" alt="Allindia captcha" src="/allindiazend/public/images/captcha/4ae305b05406c9d8b06a19ea7ff2c9d9.png"/><br/>
<input type="hidden" name="captcha[id]" value="4ae305b05406c9d8b06a19ea7ff2c9d9" title="Security Check." id="captchas" />
<input type="text" name="captcha[input]" id="captchas" value="" title="Security Check." />
The text box is occur below the img due to this <br/>
. 文本框会出现以下IMG由于这种
<br/>
。 I dont want this 'br' tag in the generated code. 我不希望在生成的代码中使用此“ br”标签。
this is my code for captcha: 这是我的验证码代码:
$captcha= new Zend_Form_Element_Captcha('captcha', array(
'id'=>'captchas',
'title'=>'Security Check.',
'captcha' => array(
'captcha' => 'Image',
'required' => true,
'font'=>'arial.ttf',
'wordlen'=>'4',
'width'=>'80',
'height'=>'30',
'ImgAlign'=>'left',
'imgdir'=>'public/images/captcha',
'DotNoiseLevel'=>'0',
'LineNoiseLevel'=>'0',
'Expiration'=>'1000',
'fontsize'=>'16',
'gcFreq'=>'10',
'ImgAlt'=>'Allindia captcha',
'imgurl'=>'/allindiazend/public/images/captcha',
'GcFreq'=>'5'
)));
can any one help me plz. 谁能帮助我。
This doesn't have to do anything with the configuration of the captcha itself, but with the form-element. 这与验证码本身的配置无关,而与表单元素无关。 I guess that this
<br />
is added in any of the default decorators of Zend_Form_Element_Captcha
. 我猜想
<br />
是在Zend_Form_Element_Captcha
任何默认装饰器中添加的。 Look which decorators are attached to the form like this: 查看将哪些装饰器附加到表单,如下所示:
echo '<pre>'; print_r($captcha->getDecorators()); echo '</pre>'; exit;
You'll see all decorators. 您会看到所有装饰器。 Try removing all decorators step by step to see which of them generates the
<br />
. 尝试逐步删除所有装饰器,以查看哪个装饰器会生成
<br />
。 Remove it completly or if it is necessary override it with your own decorator omitting the <br />
. 完全删除它,或者如有必要,请使用自己的装饰器将其覆盖,而忽略
<br />
。
I usually do something like this 我通常会做这样的事情
foreach($this->getElements() as $element) {
$element->removeDecorator('HtmlTag')
->removeDecorator('Label')
->addDecorator('Label');
}
gets rid of the default Decorators and creates blank ones 摆脱默认的装饰器并创建空白装饰器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.