SilverWare Spam Guard Module.

Installs: 397

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 2

Open Issues: 0


1.0.4 2018-09-14 05:09 UTC

This package is not auto-updated.

Last update: 2024-06-08 18:27:38 UTC


Latest Stable Version Latest Unstable Version License

A form spam protection module for SilverStripe v4.




Installation is via Composer:

$ composer require silverware/spam-guard


As with all SilverStripe modules, configuration is via YAML. An extension to the base Form class is applied via config.yml. Configuration is also used to define the default Spam Guard instance via the SilverStripe dependency injector:

    class: SilverWare\SpamGuard\Guards\SimpleSpamGuard

The default instance SimpleSpamGuard uses a honeypot approach for preventing spam, combined with a minimum form submission time, defined by the timeLimit property.


Once installed, you can enable simple spam protection on your forms by using the following code:

$form = Form::create( ... );

if ($form->hasMethod('enableSpamProtection')) {

By using hasMethod to check for the spam protection method, instead of hasExtension, we enable interoperability between this extension and the SilverStripe SpamProtection extension with no changes required to the form code.


The enableSpamProtection method accepts an optional array of arguments with the following keys:

  • class - class of the Spam Guard instance to use
  • name - name of the Spam Guard form field
  • title - title of the Spam Guard form field
  • insertBefore - insert the Spam Guard form field before a field with this name
  • insertAfter - insert the Spam Guard form field after a field with this name

For example:

if ($form->hasMethod('enableSpamProtection')) {
        'class' => CustomSpamGuard::class,
        'name' => 'CustomSpamGuard'
        'title' => 'Tasty Spam',
        'insertAfter' => 'Message'

Writing your own Spam Guard class

Spam Guard instances must implement the SilverWare\SpamGuard\Interfaces\SpamGuard interface. Your implementation must include the following methods:

  • getFormField() - answers the form field responsible for spam protection
  • getDefaultName() - answers the default name for the form field
  • getDefaultTitle() - answers the default title for the form field


Please use the GitHub issue tracker for bug reports and feature requests.


Your contributions are gladly welcomed to help make this project better. Please see contributing for more information.



Colin Tucker Praxis Interactive
Colin Tucker Praxis Interactive


BSD-3-Clause © Praxis Interactive