2009年3月21日星期六

Re: [fw-core] My_Captcha_Image

I'm not a Zend form experienced user, and I can't answer you totally...
But after looking Zend_Form_Element_Captcha::setCaptcha() method, I
think something like that :

$captchaimage = new My_Captcha_Image();

$this->addElement('captcha', 'captcha', array(
'label' => 'Word Verification',
'description' => 'Please verify that you are human',
'helper' => null,
'order' => 4,
'captcha' => $captchaimage
));

Would works, because setCaptcha accept both Zend_Captcha_Adapter
instance and options array.
I can also be totally wrong, but maybe try to give to the 'captcha'
index the value 'My_Captcha_Image' instead of 'Image', if you want your
element to instanciate it.

Hope one of this answer will help...
Lucas

zendlearner a écrit :
> Hi, I am having the same problem and I don't know how to use
> My/Captcha/Image.php instead of Zend/Captcha/Image.php when I create form
> element using new Zend_Form_Element_Captcha.
>
> $captchaimage = new My_Captcha_Image();
>
> $this->addElement('captcha', 'captcha', array(
> 'label' => 'Word Verification',
> 'description' => 'Please verify that you are human',
> 'helper' => null,
> 'order' => 4,
> 'captcha' => array(
> 'captcha' => 'Image',
> 'wordLen' => 6,
> 'timeout' => 300,
> 'font' => 'pics/captcha/DeJaVuSansMono.ttf',
> 'fontSize' => 30,
> 'imgDir' => 'pics/captcha/img',
> 'imgUrl' => 'http://foo/pics/captcha/img'
> )
> ));
>
>
>
>
> Raavi Raaj wrote:
>
>> Hi,
>>
>> I would like to extend the Image adapter for the Captcha element.
>> I have done so and placed it in My/Captcha/Image.php
>>
>> *My question...*
>> I have no clue how to use my adapter for the captcha.
>>
>> *This is how I define and add the element*
>> $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' =>
>> array('captcha' => 'Image', 'wordLen' => 4)));
>> $this->addElement($captcha);
>>
>> All help is appreciated.
>>
>> -R
>>
>> P.S.
>> - I have a canventional setup
>> - All my forms extend My_Form
>>
>>
>>
>
>

没有评论: