我在zend框架應用程序中的表單中有以下代碼。驗證Zend_Captcha_Image在窗體中使用時
$captcha = new Zend_Form_Element_Captcha('captcha', array(
'label' => "",
'captcha' => 'image',
'captchaOptions' => array(
'captcha' => 'image',
'font'=> APPLICATION_PATH . '/../public_html/assets/fonts/akbar.ttf',
'imgDir'=> APPLICATION_PATH . '/../public_html/assets/captcha/',
'imgUrl'=> '/assets/captcha/',
'wordLen' => 1,
'fsize'=>20,
'height'=>60,
'width'=>200,
'gcFreq'=>50,
'expiration' => 300)
));
並且表單元素的顯示如預期。
當我嘗試使用以下代碼驗證表單時,即使正確輸入驗證碼,它也會返回錯誤。
if($this->getRequest()->isPost()) {
if($this->view->form->isValid($_POST)) {
關於如何正確驗證它的任何解決方案都將非常有幫助。
感謝 尼扎姆
如果您刪除了captcha元素,一切正常嗎? – Marcin 2011-05-07 03:08:25
是的,只有驗證碼驗證失敗。我發現,當表單請求被做成新的captcha被生成。但我無法理解如何驗證它,並在表單內進行驗證。 – Nizam 2011-05-07 07:39:11