Zend 1.11.9 表单装饰器/验证码

发布于 2024-11-24 13:14:35 字数 1084 浏览 2 评论 0原文

在新的 Zend Framework 版本 1.11.9 中,如果我想在表单中使用验证码,这可以是一个简单的Figlet,验证码不会显示在渲染的表单中。 有没有人遇到过这个问题,我一直在搜索并将其与以前的版本(Zend/Form/Element/Captcha.php)进行比较,我注意到我必须为此元素指定 Captcha 装饰器。 有没有更好的解决方案,这个装饰器不应该默认使用吗?

   //Add a captcha
    $this->addElement('captcha', 'captcha', array(
        'label'      => 'Please enter the 5 letters displayed below:',
        'required'   => true,
        'captcha'    => array(
            'captcha' => 'Figlet',
            'wordLen' => 5,
            'timeout' => 300
        )
    ));

这是代码,如果我在 Zend 1.11.9 中使用它,则不会显示 capctha, 我要做的就是将“装饰器”添加到 capctha 的选项中,并且必须在那里指定所有装饰器。

   //Add a captcha
    $this->addElement('captcha', 'captcha', array(
        'label'      => 'Please enter the 5 letters displayed below:',
        'required'   => true,
        'captcha'    => array(
            'captcha' => 'Figlet',
            'wordLen' => 5,
            'timeout' => 300
        ),
        'decorators' => array('Captcha', 'Errors', 'Labels', etc)
    ));

In the new Zend Framework version 1.11.9 if I want to use a captcha in my form this can be a simple Figlet, the captcha is not shown in the rendered form.
Has anyone encountered this issue, I've been searching and comparing it with the previous release, (Zend/Form/Element/Captcha.php) and what i noticed is that I must specify the Captcha decorator for this element.
Is there a better solution, shouldn't this decorator been used by default?

   //Add a captcha
    $this->addElement('captcha', 'captcha', array(
        'label'      => 'Please enter the 5 letters displayed below:',
        'required'   => true,
        'captcha'    => array(
            'captcha' => 'Figlet',
            'wordLen' => 5,
            'timeout' => 300
        )
    ));

This is the code, if I use this in Zend 1.11.9 the capctha is not displayed,
What I had to do was to add 'decorators' to the options of teh capctha and had to specify there all the decorators.

   //Add a captcha
    $this->addElement('captcha', 'captcha', array(
        'label'      => 'Please enter the 5 letters displayed below:',
        'required'   => true,
        'captcha'    => array(
            'captcha' => 'Figlet',
            'wordLen' => 5,
            'timeout' => 300
        ),
        'decorators' => array('Captcha', 'Errors', 'Labels', etc)
    ));

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

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

发布评论

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

评论(3

極樂鬼 2024-12-01 13:14:35

我遇到了同样的问题。在 Zend Framework 问题跟踪器上发布了错误报告: http://framework.zend.com/issues /browse/ZF-11609

希望尽快得到解决。我检查了 1.11.9 更改日志:recaptcha 组件发生了更改。也许这就是原因...

I've encountered the same problem. Posted a bug report on Zend Framework issue tracker: http://framework.zend.com/issues/browse/ZF-11609

Hope it will get resolved soon. I've checked the 1.11.9 changelog: there was a change at the recaptcha component. Maybe that's the reason...

输什么也不输骨气 2024-12-01 13:14:35

我可以确认这一点。为了向您展示一些代码,在 ZF 1.11.8 中,这是开箱即用的:

        $captcha = new Zend_Form_Element_Captcha('captcha', array(
        'label' => 'Security Check',
        'required' => true,
        'captcha' => array(
            'captcha' => 'Image',
            'font' => APPLICATION_PATH . '/../data/fonts/AllerDisplay.ttf',
            'fontSize' => '24',
            'wordLen' => 6,
            'height' => '50',
            'width' => '150',
            'imgDir' => APPLICATION_PATH . '/../public/images/captcha',
            'imgUrl' => Zend_Controller_Front::getInstance()->getBaseUrl() . '/images/captcha',
        )
    ));

在 1.11.9 中,它不会渲染图像标签。此行为不限于线程开启者所述的 Zend_Captcha_Image。

I can confirm this. To show you some code, in ZF 1.11.8 this works out of the box:

        $captcha = new Zend_Form_Element_Captcha('captcha', array(
        'label' => 'Security Check',
        'required' => true,
        'captcha' => array(
            'captcha' => 'Image',
            'font' => APPLICATION_PATH . '/../data/fonts/AllerDisplay.ttf',
            'fontSize' => '24',
            'wordLen' => 6,
            'height' => '50',
            'width' => '150',
            'imgDir' => APPLICATION_PATH . '/../public/images/captcha',
            'imgUrl' => Zend_Controller_Front::getInstance()->getBaseUrl() . '/images/captcha',
        )
    ));

In 1.11.9 it doesn't render the image tag. This behavoir is not limited to Zend_Captcha_Image as stated by the thread opener.

失眠症患者 2024-12-01 13:14:35

我使用的是最新版本的ZF
并不

$captchaElement = new Zend_Form_Element_Captcha
        (
            'signup',
            array('captcha' => array(
            'captcha' => 'Figlet',
            'wordLen' => 6,
            'timeout' => 600,       
            ))
        );

显示任何内容 =-(

这是页面上的源代码:

<dt id="signup-input-label"><label for="signup-input" class="required">Please type in the words below to continue</label></dt>

<dd id="signup-element">

<input type="hidden" name="signup[id]" value="9038166aac96370c73b9d474e8e20475" id="signup-id">

<input type="text" name="signup[input]" id="signup-input" value="">

I'm using the latest version of ZF
and

$captchaElement = new Zend_Form_Element_Captcha
        (
            'signup',
            array('captcha' => array(
            'captcha' => 'Figlet',
            'wordLen' => 6,
            'timeout' => 600,       
            ))
        );

Show nothing =-(

This is the source on the page:

<dt id="signup-input-label"><label for="signup-input" class="required">Please type in the words below to continue</label></dt>

<dd id="signup-element">

<input type="hidden" name="signup[id]" value="9038166aac96370c73b9d474e8e20475" id="signup-id">

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