2
我使用Zend_Form
創建的驗證碼是這樣的:Zend的驗證碼HTML
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.">
任何想法?
謝謝
[Customize zend_form Captcha output?](http://stackoverflow.com/questions/5131743/customize-zend-form-captcha-output) – markus 2012-07-24 18:15:55