views:

826

answers:

4

Hi,

I am using Zend_Service_ReCaptcha in a project and wish to customize the colour scheme of the box, however I am completely stumped on which function to use to achieve this. http://framework.zend.com/manual/en/zend.form.standardElements.html#zend.form.standardElements.captcha doesn't seem to shed any light.

Answers are appreciated, thanks.

+2  A: 

You need to pass the theme option via the captcha options to the form element:

Something like:

$element = new Zend_Form_Element_Captcha('foo', array(
    'label' => "Please verify you're a human",
    'captcha' => array(
        'captcha' => 'Recaptcha',
        'timeout' => 300,
        'theme'   => 'red'
    ),
));
David Caunt
+2  A: 

Setting this options via form element params won't work! This options (“theme” and “lang”) should be passed to the service instead!

Here's *Zend_Service_ReCaptcha* constructor:

public function __construct($publicKey = null, $privateKey = null,
                                $params = null, $options = null, $ip = null)
{
…

Usage:

$options = array('theme' => 'white', 'lang' => 'ru');
$recaptcha = new Zend_Service_ReCaptcha($publicKey, $privateKey, null, $options);

$this->view->recaptcha = $recaptcha->getHtml();

Otherwise, if you wanna use form elements, you should get service object first. Try something like that:

$options = array('theme' => 'white', 'lang' => 'ru');
$form->getElement('captcha')->getCaptcha()->getService()->setOptions($options);
Sergey 'm17' Kolosov
A: 

I don't know if I should post here, but here it goes:

What is the public and private keys for? And more important, how do we set them to work?

Thank you

A: 

You get the public and private keys when you register at http://recaptcha.net/ and set them in your form as follows $recaptcha_service = new Zend_Service_ReCaptcha($public, $private);