Class \Prado\Web\UI\WebControls\TReCaptcha2
TReCaptcha2 displays a reCAPTCHA (a token displayed as an image) that can be used to determine if the input is entered by a real user instead of some program. It can also prevent multiple submits of the same form either by accident, or on purpose (ie. spamming).
The reCAPTCHA to solve (a string consisting of two separate words) displayed is automatically generated by the reCAPTCHA system at recaptcha.net. However, in order to use the services of the site you will need to register and get a public and a private API key pair, and supply those to the reCAPTCHA control through setting the \Prado\Web\UI\WebControls\setSecretKey and \Prado\Web\UI\WebControls\setSiteKey properties.
Currently the reCAPTCHA API supports only one reCAPTCHA field per page, so you MUST make sure that all your input is protected and validated by a single reCAPTCHA control. Placing more than one reCAPTCHA control on the page will lead to unpredictable results, and the user will most likely unable to solve any of them successfully.
Upon postback, user input can be validated by calling validate(). The TReCaptcha2Validator control can also be used to do validation, which provides server-side validation. Calling (@link validate()) will invalidate the token supplied, so all consecutive calls to the method - without solving a new captcha - will return false. Therefore if implementing a multi-stage input process, you must make sure that you call validate() only once, either at the end of the input process, or you store the result till the end of the processing.
The following template shows a typical use of TReCaptcha control:
<com:TReCaptcha2 ID="Captcha"
SiteKey="..."
SecretKey="..."
/>
<com:TReCaptcha2Validator ControlToValidate="Captcha"
ErrorMessage="You are challenged!" />
Class hierarchy
- \Prado\Web\UI\WebControls\TReCaptcha2 implements ICallbackEventHandler, IValidatable
- \Prado\Web\UI\ActiveControls\TActivePanel implements IActiveControl
- \Prado\Web\UI\WebControls\TPanel
- \Prado\Web\UI\WebControls\TWebControl implements IStyleable
- \Prado\Web\UI\TControl implements IRenderable, IBindable
- \Prado\TApplicationComponent
- \Prado\TComponent
Since: 3.3.1
public
|
__construct() : mixed
Creates a new callback control, sets the adapter to
TActiveControlAdapter. If you override this class, be sure to set the
adapter appropriately by, for example, by calling this constructor.
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
getTabIndex() : string
Returns the tabindex of the widget and challenge.
If other elements in your page use tabindex, it should be set to make user navigation easier. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
raiseCallbackEvent(mixed $param) : mixed
Raises callback event. The implementation of this function should raise
appropriate event(s) (e.g. OnClick, OnCommand) indicating the component
is responsible for the callback event.
|
public
|
render(mixed $writer) : mixed
Renders and replaces the panel's content on the client-side.
When render() is called before the OnPreRender event, such as when render() is called during a callback event handler, the rendering is defered until OnPreRender event is raised. |
public
|
reset() : mixed
Resets the reCAPTCHA widget.
Optional widget ID, defaults to the first widget created if unspecified. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
setTabIndex(string $value) : mixed
The tabindex of the widget and challenge.
If other elements in your page use tabindex, it should be set to make user navigation easier. Default: 0 |
public
|
|
public
|
|
public
|
|
public
|
|
protected
|
|
protected
|
|
protected
|
public
mixed
|
ChallengeFieldName
|
'g-recaptcha-response'
|