-- [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote
(on Saturday, 13 September 2008, 01:38 AM -0400):
> Can someone explain to me why the first snippet of code works while the  
> second one throws an error? Other form elements work fine when written  
> in the same way as the second snippet of code. Why not  
> Zend_Form_Element_Captcha?
> Thanks.
>
> DOES WORK
> $captcha = new Zend_Form_Element_Captcha('captcha', array(
>       'captcha' => array(
>               'captcha' => 'Figlet',
>       ),
> ));
> $captcha->setLabel('Captcha:');
>
> DOES NOT WORK
> $captcha = new Zend_Form_Element_Captcha('captcha');
> $captcha->setLabel('Captcha:')
>       ->setCaptcha(new Zend_Captcha_Figlet());

In order to ensure that all operations within the captcha element work,
we need a captcha adapter to be passed to the element on instantiation.
This can be done, as you have in the first example, by passing data to
use in the factory, or by passing a concrete instance.

We are considering refactoring to allow setting the captcha late -- but
there are a number of places that would be affected, and it would
introduce complexity that we're not sure is warranted.

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to