CCaptcha
CCaptcha renders a CAPTCHA image element.
CCaptcha is used together with
CCaptchaAction to provide
CAPTCHA
- a way of preventing site spam.
The image element rendered by CCaptcha will display a CAPTCHA image generated
by an action of class
CCaptchaAction belonging to the current controller.
By default, the action ID should be 'captcha', which can be changed by setting
captchaAction.
CCaptcha may also render a button next to the CAPTCHA image. Clicking on the button
will change the CAPTCHA image to be a new one in an AJAX way.
Since version 1.0.8, if
clickableImage is set true, clicking on the CAPTCHA image
will refresh the CAPTCHA.
A
CCaptchaValidator may be used to validate that the user enters
a verification code matching the code displayed in the CAPTCHA image.
Property Details
public string $buttonLabel;
the label for the refresh button. Defaults to 'Get a new code'.
public array $buttonOptions;
HTML attributes to be applied to the rendered refresh button element.
public string $buttonType;
the type of the refresh button. This should be either 'link' or 'button'.
The former refers to hyperlink button while the latter a normal push button.
Defaults to 'link'.
public string $captchaAction;
the ID of the action that should provide CAPTCHA image. Defaults to 'captcha',
meaning the 'captcha' action of the current controller. This property may also
be in the format of 'ControllerID/ActionID'. Underneath, this property is used
by CController::createUrl to create the URL that would serve the CAPTCHA image.
The action has to be of CCaptchaAction.
public boolean $clickableImage;
whether to allow clicking on the CAPTCHA image to refresh the CAPTCHA letters.
Defaults to false. Hint: you may want to set showRefreshButton to false if you set
this property to be true because they serve for the same purpose.
To enhance accessibility, you may set imageOptions to provide hints to end-users that
the image is clickable.
public array $imageOptions;
HTML attributes to be applied to the rendered image element.
public boolean $showRefreshButton;
whether to display a button next to the CAPTCHA image. Clicking on the button
will cause the CAPTCHA image to be changed to a new one. Defaults to true.
Method Details
|
public void registerClientScript()
|
Registers the needed client scripts.
|
protected void renderImage()
|
Renders the CAPTCHA image.
Renders the widget.