zend表单验证码问题

发布于 2024-11-02 20:10:29 字数 1451 浏览 2 评论 0原文

我正在使用 zend 形式的 zend 验证码。它工作正常,但是当它创建时,它会生成以下代码:

<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." />

由于此
,文本框出现在 img 下方。我不想在生成的代码中使用这个“br”标签。

这是我的验证码代码:

$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'
                )));

任何人都可以帮助我吗?

I am using zend captcha in zend form. 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/>. I dont want this 'br' tag in the generated code.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

要走干脆点 2024-11-09 20:10:29

这与验证码本身的配置无关,但与表单元素有关。我猜这个
被添加到 Zend_Form_Element_Captcha 的任何默认装饰器中。查看哪些装饰器附加到表单,如下所示:

echo '<pre>'; print_r($captcha->getDecorators()); echo '</pre>'; exit;

您将看到所有装饰器。尝试逐步删除所有装饰器,看看它们中的哪一个生成
。完全删除它,或者如果有必要,使用您自己的装饰器覆盖它,省略

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. 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 />. Remove it completly or if it is necessary override it with your own decorator omitting the <br />.

木有鱼丸 2024-11-09 20:10:29

我通常会做这样的事情,

foreach($this->getElements() as $element) {
    $element->removeDecorator('HtmlTag')
        ->removeDecorator('Label')
        ->addDecorator('Label');
}

摆脱默认的装饰器并创建空白的装饰器

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文