-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Meldgaard
committed
Apr 4, 2019
1 parent
3e7f134
commit d0b78f2
Showing
1 changed file
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,46 @@ | ||
# Silverstripe Recaptcha | ||
This module adds Google reCaptcha to SilverStripe 4.x, which you can use in your custom forms. | ||
|
||
##Installation | ||
## Installation | ||
```composer require lundco/silverstripe-recaptcha``` | ||
|
||
###Spamscore | ||
## Usage | ||
Put your keys and spamscore in your app/_config/app.yml | ||
```yml | ||
Lundco\SilverStripe\ReCaptcha\Form\RecaptchaField: | ||
siteKey: 'Insert site key' | ||
secretKey: 'Insert secret key' | ||
spamLevel: 0-100 | ||
``` | ||
### Spamscore | ||
In config you set the spamscore to a value from 0 to 100. Recommended value to start is 50. | ||
##TODO | ||
### Form setup | ||
Then you can use it in your forms, by using `RecaptchaForm` instead of `Form | ||
|
||
```php | ||
public function HelloForm() | ||
{ | ||
$fields = new FieldList( | ||
TextField::create('Name', _t('HelloForm.Name', 'Name')), | ||
TextField::create('Email', _t('HelloForm.Email', 'E-Mail')), | ||
TextareaField::create('Message', _t('HelloForm.Message', 'Message')), | ||
); | ||
$actions = new FieldList( | ||
FormAction::create('doSayHello')->setTitle(_t('HelloForm.Submit', 'Send')) | ||
); | ||
$required = new RequiredFields('Name', 'Email', 'Message'); | ||
$form = new RecaptchaForm($this, 'HelloForm', $fields, $actions, $required); | ||
return $form; | ||
} | ||
``` | ||
|
||
## TODO | ||
* Update module to handle v2 of recaptcha | ||
* Update module to give possibility to hide badge in v3 |