【问题标题】:Zend 1.11.9 Form decorators / captchaZend 1.11.9 表单装饰器/验证码
【发布时间】:2011-10-07 07:20:42
【问题描述】:

在新的 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 中使用它,验证码不会显示, 我必须做的是在验证码的选项中添加“装饰器”,并且必须在那里指定所有装饰器。

   //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)
    ));

【问题讨论】:

    标签: php zend-form captcha zend-decorators


    【解决方案1】:

    我正在使用最新版本的 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="">
    

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • 是的,可能,感谢您的回复..如果您得到一些反馈,请也通知我。再次感谢
      【解决方案3】:

      我可以确认这一点。为了向您展示一些代码,在 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。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-01-10
        • 2012-10-23
        • 2011-07-13
        • 2011-01-24
        • 1970-01-01
        • 2010-11-19
        • 2011-06-24
        相关资源
        最近更新 更多