PHP 클래스 yii\captcha\Captcha

Captcha is used together with CaptchaAction to provide CAPTCHA - a way of preventing website spamming. The image element rendered by Captcha will display a CAPTCHA image generated by an action whose route is specified by [[captchaAction]]. This action must be an instance of CaptchaAction. When the user clicks on the CAPTCHA image, it will cause the CAPTCHA image to be refreshed with a new CAPTCHA. You may use CaptchaValidator to validate the user input matches the current CAPTCHA verification code. The following example shows how to use this widget with a model attribute: php echo Captcha::widget([ 'model' => $model, 'attribute' => 'captcha', ]); The following example will use the name property instead: php echo Captcha::widget([ 'name' => 'captcha', ]); You can also use this widget in an [[\yii\widgets\ActiveForm|ActiveForm]] using the [[\yii\widgets\ActiveField::widget()|widget()]] method, for example like this: php field($model, 'captcha')->widget(\yii\captcha\Captcha::classname(), [ configure additional widget properties here ]) ?>
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\widgets\InputWidget
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$captchaAction the route of the action that generates the CAPTCHA images. The action represented by this route must be an action of CaptchaAction. Please refer to [[\yii\helpers\Url::toRoute()]] for acceptable formats.
$imageOptions HTML attributes to be applied to the CAPTCHA image tag.
$options the HTML attributes for the input tag.
$template the template for arranging the CAPTCHA image tag and the text input tag. In this template, the token {image} will be replaced with the actual image tag, while {input} will be replaced with the text input tag.

공개 메소드들

메소드 설명
checkRequirements ( ) : string Checks if there is graphic extension available to generate CAPTCHA images.
init ( ) Initializes the widget.
registerClientScript ( ) Registers the needed JavaScript.
run ( ) Renders the widget.

보호된 메소드들

메소드 설명
getClientOptions ( ) : array Returns the options for the captcha JS widget.

메소드 상세

checkRequirements() 공개 정적인 메소드

This method will check the existence of ImageMagick and GD extensions.
public static checkRequirements ( ) : string
리턴 string the name of the graphic extension, either "imagick" or "gd".

getClientOptions() 보호된 메소드

Returns the options for the captcha JS widget.
protected getClientOptions ( ) : array
리턴 array the options

init() 공개 메소드

Initializes the widget.
public init ( )

registerClientScript() 공개 메소드

Registers the needed JavaScript.

run() 공개 메소드

Renders the widget.
public run ( )

프로퍼티 상세

$captchaAction 공개적으로 프로퍼티

the route of the action that generates the CAPTCHA images. The action represented by this route must be an action of CaptchaAction. Please refer to [[\yii\helpers\Url::toRoute()]] for acceptable formats.
public $captchaAction

$imageOptions 공개적으로 프로퍼티

HTML attributes to be applied to the CAPTCHA image tag.
또한 보기: yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public $imageOptions

$options 공개적으로 프로퍼티

the HTML attributes for the input tag.
또한 보기: yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public $options

$template 공개적으로 프로퍼티

the template for arranging the CAPTCHA image tag and the text input tag. In this template, the token {image} will be replaced with the actual image tag, while {input} will be replaced with the text input tag.
public $template