diff --git a/README.md b/README.md index e0400d7..eb6dce3 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,38 @@ -# SilverStripe honeypot +# SilverStripe Honey Pot -For a SilverStripe `2.4` compatible version use the branch `1.0` +A SilverStripe 4.x compatible version of camspiers/honeypot ## Installation (with composer) - $ composer require camspiers/honeypot + $ composer require heyday/silverstripe-honeypot -Set the default spam protector in *mysite/_config/spamprotection.yml* +Set the default spam protector in *app/_config/spamprotection.yml* --- name: spamprotection --- - FormSpamProtectionExtension: - default_spam_protector: HoneyPotSpamProtector \ No newline at end of file + SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension: + default_spam_protector: Heyday\SilverStripe\HoneyPot\HoneyPotSpamProtector + +Or, on a form by form basis + + use Heyday\SilverStripe\HoneyPot\HoneyPotField; + use SilverStripe\Forms\Form; + use SilverStripe\Control\Controller; + use SilverStripe\Forms\FieldList; + + /** + * Class SomeForm + */ + class SomeForm extends Form + { + /** + * @param Controller $controller + */ + public function __construct(Controller $controller) + { + $fields = new FieldList(); + $fields->push(new HoneyPotField('Website')); // 'Website' here can be any old string + ... + } + } \ No newline at end of file diff --git a/code/HoneyPotField.php b/code/HoneyPotField.php index 2115faf..f3b9787 100644 --- a/code/HoneyPotField.php +++ b/code/HoneyPotField.php @@ -1,8 +1,20 @@ value) || $this->value === '')) { @@ -18,6 +30,10 @@ public function validate($validator) return true; } + /** + * @param array $properties + * @return \SilverStripe\ORM\FieldType\DBHTMLText + */ public function FieldHolder($properties = array()) { return $this->renderWith('HoneyPotField_holder'); diff --git a/code/HoneyPotSpamProtector.php b/code/HoneyPotSpamProtector.php index 331a143..2769c3d 100644 --- a/code/HoneyPotSpamProtector.php +++ b/code/HoneyPotSpamProtector.php @@ -1,23 +1,27 @@