yii\captcha\Captcha::run PHP Метод

run() публичный Метод

Renders the widget.
public run ( )
    public function run()
    {
        $this->registerClientScript();
        if ($this->hasModel()) {
            $input = Html::activeTextInput($this->model, $this->attribute, $this->options);
        } else {
            $input = Html::textInput($this->name, $this->value, $this->options);
        }
        $route = $this->captchaAction;
        if (is_array($route)) {
            $route['v'] = uniqid();
        } else {
            $route = [$route, 'v' => uniqid()];
        }
        $image = Html::img($route, $this->imageOptions);
        echo strtr($this->template, ['{input}' => $input, '{image}' => $image]);
    }

Usage Example

Пример #1
0
 /**
  * @inheritdoc
  * 
  * Takes the decision of rendering the widget or not depending on the number 
  * of requests made from the client IP.
  */
 public function run()
 {
     $captchaControl = new CaptchaControl(['model' => $this->model]);
     if ($captchaControl->hasReachedRequestNumber()) {
         parent::run();
     }
 }