silverstripe - 如何在表单上实现新的隐形 reCAPTCHA?

标签 silverstripe

我正在尝试让谷歌 reCAPTCHA 的新“隐形”版本在我的表单上工作。

我正在使用 https://github.com/UndefinedOffset/silverstripe-nocaptcha

根据文档,您应该能够在 config.yml 中进行更改,我认为它是不可见的?

default_size: "invisible"

——
public function HelloForm() {
        $fields = new FieldList(
            new TextField('Name'),
            new EmailField('Email'),
            new TextareaField('Message')
        );
        $actions = new FieldList(
            new FormAction('doSubmitHelloForm', 'Submit')
        );

        $form = new Form($this, 'HelloForm', $fields, $actions);

        $form->enableSpamProtection()
            ->fields()->fieldByName('Captcha')
            ->setTitle("Spam protection")
            ->setDescription("Please tick the box to prove you're a human and help us stop spam.");

        return $form;
    }

config.yml
NocaptchaField:
  site_key: "MYKEYINHERE" #Your site key (required)
  secret_key: "MYKEYINHERE" #Your secret key (required)
  verify_ssl: true #Allows you to disable php-curl's SSL peer verification by setting this to false (optional, defaults to true)
  default_theme: "light" #Default theme color (optional, light or dark, defaults to light)
  default_type: "image" #Default captcha type (optional, image or audio, defaults to image)
  default_size: "invisible" #Default size (optional, normal, compact or invisible, defaults to normal)
  proxy_server: "" #Your proxy server address (optional)
  proxy_auth: "" #Your proxy server authentication information (optional)

但是验证码仍在显示,我错过了什么吗? (请注意,我只是在我的本地开发机器 atm 上测试这个)。

enter image description here

最佳答案

好的,这里有两个问题。

  • 我最初使用的是旧版本的 nocaptcha 模块。然后我升级到 0.3.0(发布时的最新版本)并且验证码按照我们的需要隐藏了。
  • 模块中有一个错误,这意味着它在提交表单时一直显示错误消息(说需要勾选验证码)。作者现在已经修复了这个问题,并将在 0.4.0 中标记这个版本。

  • :)

    关于silverstripe - 如何在表单上实现新的隐形 reCAPTCHA?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43200694/

    相关文章:

    php - 使用 DB::query 处理 Silverstripe 中的 MySQL 错误

    php - SilverStripe限制3级子页面

    javascript - renderWith 输出在控制台中可见,但不更新浏览器

    styles - silverstripe - 将样式添加到编辑器上的 'styles' 下拉菜单

    php - 更改 silverstripes 'mysite' 文件夹的名称

    mysql - 如何对查询进行分组并随机获得每组第 n 个项目

    php - Silverstripe 4 - 访问核心方法

    php - 如何在 Silverstripe 中使用第二个数据库

    php - SilverStripe - 根据下拉选择创建分页

    silverstripe - o在 SilverStripe 3 中嵌入字段