public function onSubmit(array $data = array())
 {
     unset($data['enabled']);
     try {
         $captcha = new Zend_Captcha_ReCaptcha($data);
         $captcha->render();
         $this->_data = $data;
         return true;
     } catch (Exception $e) {
         $this->getForm()->addError('Test failed: ' . $e->getMessage());
         return false;
     }
 }
Exemple #2
0
 /** @group ZF-10991 */
 public function testRenderWillUseElementNameWhenRenderingNoScriptFields()
 {
     $captcha = new Zend_Captcha_ReCaptcha();
     $pubKey = 'pubKey';
     $privKey = 'privKey';
     $captcha->setPubkey($pubKey)->setPrivkey($privKey);
     $element = new Zend_Form_Element_Captcha('captcha', array('captcha' => $captcha, 'belongsTo' => 'contact'));
     $view = new Zend_View();
     $html = $captcha->render($view, $element);
     $this->assertContains('contact[recaptcha_challenge_field]', $html);
     $this->assertContains('contact[recaptcha_response_field]', $html);
 }