使用Zend PHP进行Recaptcha样式设计

4 php zend-framework

我在项目中使用Zend_Service_ReCaptcha并希望自定义框的颜色方案,但是我完全不知道要使用哪个函数来实现这一点. http://framework.zend.com/manual/en/zend.form.standardElements.html#zend.form.standardElements.captcha似乎没有任何消息.

感谢您的回答.

Ser*_*sov 8

通过表单元素参数设置此选项将不起作用!这个选项(" 主题 "和" lang ")应该传递给服务!

这是Zend_Service_ReCaptcha构造函数:

public function __construct($publicKey = null, $privateKey = null,
                                $params = null, $options = null, $ip = null)
{
…
Run Code Online (Sandbox Code Playgroud)

用法:

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

$this->view->recaptcha = $recaptcha->getHtml();
Run Code Online (Sandbox Code Playgroud)

否则,如果您想使用表单元素,则应首先获取服务对象.尝试类似的东西:

$options = array('theme' => 'white', 'lang' => 'ru');
$form->getElement('captcha')->getCaptcha()->getService()->setOptions($options);
Run Code Online (Sandbox Code Playgroud)