SilverWare\Recaptcha\Fields\RecaptchaField
An extension of the form field class for a Google Recaptcha spam prevention field.
- Author: Colin Tucker <colin@praxis.net.au>
- Copyright: 2018 Praxis Interactive
- License: https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
Synopsis
class RecaptchaField
extends FormField
{
- // members
- private static array $default_config = ;
- private static array $dependencies = ;
- private static string $public_api_key = '';
- private static string $private_api_key = '';
- private static string $recaptcha_script_url = 'https://www.google.com/recaptcha/api.js';
- private static string $recaptcha_verify_url = 'https://www.google.com/recaptcha/api/siteverify';
- private static string $alert_class = 'alert alert-warning';
- private static string $field_class = 'g-recaptcha';
- private static string $post_var = 'g-recaptcha-response';
- protected $config;
- // methods
- public void __construct()
- public $this setConfig()
- public mixed getConfig()
- public string Type()
- public DBHTMLText Field()
- public array getAttributes()
- public array getDataAttributes()
- public boolean validate()
- public boolean hasKeys()
- public string getAlertClass()
- public string getFieldClass()
- protected array getFieldConfig()
- protected string getScriptURL()
- protected string getVerifyURL()
- protected HTTPRequest getCurrentRequest()
- protected array verify()
- protected array getVerifyParams()
Hierarchy
Extends
- SilverStripe\Forms\FormField
Members
private
- $alert_class
—
string
Defines the class names to use for alert messages. - $default_config
—
array
An array which defines the default configuration for instances. - $dependencies
—
array
Defines the injector dependencies for this object. - $field_class
—
string
Defines the class name to use for the Recaptcha field. - $post_var
—
string
Defines the name of the response POST variable. - $private_api_key
—
string
Defines the private key for the Recaptcha API. - $public_api_key
—
string
Defines the public key for the Recaptcha API. - $recaptcha_script_url
—
string
Defines the URL for the Recaptcha client-side script. - $recaptcha_verify_url
—
string
Defines the URL for the Recaptcha server-side verification.
protected
- $config
—
array
An array which holds the configuration for an instance.
Methods
protected
- getCurrentRequest() — Answers the current HTTP request object from the controller.
- getFieldConfig() — Answers the field config for the receiver.
- getScriptURL() — Answers the URL for the Recaptcha client-side script.
- getVerifyParams() — Answers an array of parameters for the verification POST request.
- getVerifyURL() — Answers the URL for the Recaptcha server-side verification.
- verify() — Verifies the given POST variable response using the configured HTTP client.
public
- __construct() — Constructs the object upon instantiation.
- Field() — Renders the field for the template.
- Type() — Answers the field type for the template.
- getAlertClass() — Answers the class names to use for any alert messages.
- getAttributes() — Answers an array of HTML attributes for the field.
- getConfig() — Answers either the named config value, or the config array.
- getDataAttributes() — Answers an array of data attributes for the field.
- getFieldClass() — Answers the class name to use for the field element.
- hasKeys() — Answers true if both the public and private API keys are defined.
- setConfig() — Defines either the named config value, or the config array.
- validate() — Answers true if the value is valid for the receiver.