{"id":19225032,"url":"https://github.com/cyber-duck/silverstripe-recaptcha","last_synced_at":"2026-03-12T13:44:59.061Z","repository":{"id":33847192,"uuid":"153784481","full_name":"Cyber-Duck/SilverStripe-Recaptcha","owner":"Cyber-Duck","description":"Standard reCAPTCHA and invisible reCAPTCHA form fields for SilverStripe","archived":false,"fork":false,"pushed_at":"2023-09-08T10:11:40.000Z","size":21,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2024-09-18T18:47:32.659Z","etag":null,"topics":["google","php","recaptcha","silverstripe","silverstripe-4"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cyber-Duck.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-19T13:09:00.000Z","updated_at":"2023-09-08T10:11:44.000Z","dependencies_parsed_at":"2022-08-09T00:17:58.691Z","dependency_job_id":null,"html_url":"https://github.com/Cyber-Duck/SilverStripe-Recaptcha","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyber-Duck%2FSilverStripe-Recaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyber-Duck%2FSilverStripe-Recaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyber-Duck%2FSilverStripe-Recaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyber-Duck%2FSilverStripe-Recaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cyber-Duck","download_url":"https://codeload.github.com/Cyber-Duck/SilverStripe-Recaptcha/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223842137,"owners_count":17212323,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google","php","recaptcha","silverstripe","silverstripe-4"],"created_at":"2024-11-09T15:13:49.311Z","updated_at":"2025-10-20T08:08:58.443Z","avatar_url":"https://github.com/Cyber-Duck.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Silverstripe-Recaptcha\nStandard reCAPTCHA and invisible reCAPTCHA form fields for SilverStripe\n\n[![Latest Stable Version](https://poser.pugx.org/cyber-duck/silverstripe-recaptcha/v/stable)](https://packagist.org/packages/cyber-duck/silverstripe-recaptcha)\n[![Latest Unstable Version](https://poser.pugx.org/cyber-duck/silverstripe-recaptcha/v/unstable)](https://packagist.org/packages/cyber-duck/silverstripe-recaptcha)\n[![Total Downloads](https://poser.pugx.org/cyber-duck/silverstripe-recaptcha/downloads)](https://packagist.org/packages/cyber-duck/silverstripe-recaptcha)\n[![License](https://poser.pugx.org/cyber-duck/silverstripe-recaptcha/license)](https://packagist.org/packages/cyber-duck/silverstripe-recaptcha)\n\nAuthor: [Andrew Mc Cormack](https://github.com/Andrew-Mc-Cormack)\n\n__For SilverStripe 4.*__\n\n## Installation\n\nAdd the following to your composer.json file and run /dev/build?flush=all\n\n```json\n{  \n    \"require\": {  \n        \"cyber-duck/silverstripe-recaptcha\": \"4.0.*\"\n    }\n}\n```\n\n## Standard Recaptcha\n\nAdd 2 .env vars with your recaptcha keys\n\n```\nRECAPTCHA_SITE_KEY=\"0000000000\"\nRECAPTCHA_SECRET_KEY=\"0000000000\"\n```\n\nAdd the field to any form on your site just as you would any other field.\nPass in: \n- the field name.\nAlso add the field to the required fields list.\n\n```php\nuse CyberDuck\\Recaptcha\\Forms\\RecaptchaField;\n\n$fields = FieldList::create([\n\tRecaptchaField::create('Recaptcha');\n]);\n\n$validator = RequiredFields::create([\n    'Recaptcha'\n]);\n```\n\n## Invisible Recaptcha\n\nAdd 2 .env vars with your recaptcha keys\n\n```\nRECAPTCHA_INVISIBLE_SITE_KEY=\"0000000000\"\nRECAPTCHA_INVISIBLE_SECRET_KEY=\"0000000000\"\n```\n\nAdd the field to any form on your site just as you would any other field.\nPass in: \n- the field name, \n- the form ID (without #)\n- the HTML element ID (without #) or selector (such as button) to render the reCAPTCHA widget.\nAlso add the field to the required fields list.\n\n```php\nuse CyberDuck\\Recaptcha\\Forms\\InvisibleRecaptchaField;\n\n$fields = FieldList::create([\n\tInvisibleRecaptchaField::create(\n\t    'Recaptcha', \n\t    'MemberLoginForm_LoginForm',\n\t    'MemberLoginForm_LoginForm_action_doLogin'\n\t);\n]);\n\n$validator = RequiredFields::create([\n    'Recaptcha'\n]);\n```\n\n## Working with jQuery and AJAX\n\nIf you would like to use the reCAPTCHA with AJAX you can copy the InvisibleRecaptcha.ss from the module templates folder into your theme templates folder\n\n```javascript\n\u003cscript type=\"text/javascript\"\u003e\n    var onRecaptchaFormSubmit = function(token) {\n        document.getElementById('{$FormID}').submit();\n    };\n    var onloadCallback = function() {\n        grecaptcha.render('{$Container}', {\n        'sitekey' : '{$SiteKey}',\n        'callback' : onRecaptchaFormSubmit\n        });\n    };\n\u003c/script\u003e\n```\n\nAnd just update the onRecaptchaFormSubmit function to use jQuery to select and submit the form\n\n```javascript\n\u003cscript type=\"text/javascript\"\u003e\n    var onRecaptchaFormSubmit = function(token) {\n        $('#{$FormID}').submit();\n    };\n    var onloadCallback = function() {\n        grecaptcha.render('{$Container}', {\n        'sitekey' : '{$SiteKey}',\n        'callback' : onRecaptchaFormSubmit\n        });\n    };\n\u003c/script\u003e\n\n```\n\nIn your AJAX success function, if your form fails validation you can call onloadCallback() to re-render the reCAPTCHA\n\n```javascript\nonloadCallback()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyber-duck%2Fsilverstripe-recaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyber-duck%2Fsilverstripe-recaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyber-duck%2Fsilverstripe-recaptcha/lists"}