【问题标题】:Zend captcha htmlZend 验证码 html
【发布时间】:2012-07-22 20:38:15
【问题描述】:

我正在使用Zend_Form 创建这样的验证码:

class Form_Signup extends Zend_Form {

    public function __construct( array $options = null ) {

        // set method
        $this->setMethod('post');

        // other elements here        

        // captcha 
        $captcha = new Zend_Form_Element_Captcha('captcha', array(
                'id'=>'captcha',
                'title'=>'Security Check.',
                'captcha' => array(
                'captcha' => 'Image',
                'required' => true,
                'font'=> 'fonts/ARIALN.TTF',
                'wordlen'=>'4',
                'width'=>'200',
                'height'=>'50',
                'ImgAlign'=>'left',
                'DotNoiseLevel'=>'30',
                'LineNoiseLevel'=>'7', 
                'Expiration'=>'1000',
                'fontsize'=>'30',
                'gcFreq'=>'10',
                'imgdir'=> 'images/captcha/',
                'ImgAlt'=>'Captcha',
                'imgurl'=>'/images/captcha/'
                )));
        $captcha->removeDecorator('HtmlTag')
        ->removeDecorator('Label')
        ->addDecorator('Label');        

        // add captcha
        $this->addElement( $captcha );          
        $this->setDecorators( array( array( 'ViewScript', array( 'viewScript' => 'signup/signup-form.phtml' ) ) ) );    
    } 

}

它正在生成这样的 HTML:

<img width="200" height="50" alt="Captcha" src="/images/captcha/cabf4d4d759ae8e4b7404b95e032e231.png">
<input type="hidden" name="captcha[id]" value="cabf4d4d759ae8e4b7404b95e032e231" title="Security Check." id="captcha">
<input type="text" name="captcha[input]" id="captcha" value="" title="Security Check.">

但我想要像这样的图像下方的验证码文本框:

<img width="200" height="50" alt="Captcha" src="/images/captcha/cabf4d4d759ae8e4b7404b95e032e231.png">
<br />
<input type="hidden" name="captcha[id]" value="cabf4d4d759ae8e4b7404b95e032e231" title="Security Check." id="captcha">
<input type="text" name="captcha[input]" id="captcha" value="" title="Security Check.">

有什么想法吗?

谢谢

【问题讨论】:

标签: php html zend-framework decorator captcha


【解决方案1】:

Zend Captcha 元素装饰器并不复杂。解决这个问题的最佳方法是创建我们自己的装饰器。一旦你完成它。您可以根据需要更改顺序

你可以找到完整的答案here

如果你不赶时间,如果你有足够的时间,那么请通过 Methew 的 this article 解释如何使用装饰器。

几乎与我问过here 的问题相同,我不想创建一个单独的装饰器类,但没有得到任何正确的答案。然后我做了一些 css 技巧并迫使 &lt;input type='text'&gt; 下线。所以唯一的解决方案是生成自定义验证码装饰器类。

如果你在那里没有得到任何东西,请告诉我。谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多