On Wed, Oct 9, 2013 at 5:16 AM, MGP <[email protected]> wrote:
> I'm trying to setup a captcha in a form.
>
> I've added the zend form element captcha to the form, and printed it with
> formElement($form->get...);
>
> Everything works ok. The image is displayed, the input field is created. But
> when i submit my form, i always get an empty captcha error.
>
> $form->getData()
>
> Array
> (
>     [email] => [email protected]
>     [captcha] => Array
> )
>
> $_POST
>
> Array
> (
>     [email] => [email protected]
>     [captcha] => Array
>         (
>             [id] => 0ea5a030a05003e2dbf60b3056fb8f18
>             [input] => dgdfgdfg
>         )
>
> )
>
>
> $form->getInputFilter()->getMessages();
>
> Array
> (
>     [captcha] => Array
>         (
>             [missingValue] => Empty captcha value
>         )
>
> )
>
> $form = new Form();
>
> $captchaImage =  new \Zend\Captcha\Image(  array(
>                 'font' =>'./fonts/arial.ttf',
>                 'width' => 250,
>                 'height' => 100,
>                 'dotNoiseLevel' => 40,
>                 'lineNoiseLevel' => 3)
>         );
>         $captchaImage->setImgDir('captcha');
>         $captchaImage->setImgUrl('captcha');
>
>         $form->add(array(
>             'type' => 'Zend\Form\Element\Captcha',
>             'name' => 'captcha',
>             'options' => array(
>                 'label' => 'captcha',
>                 'captcha' => $captchaImage,
>             ),
>         ));
>
> (...)
>
> Why might be happening?

My guess is that the session cookie is getting overwritten, or the
session is getting clobbered between requests. Can you dump the
contents of $_SESSION on the initial request and on the final to see
if perhaps that is the case?


-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to