/** * Renders the widget. */ public function run() { if ($this->hasModel() && $this->activeField) { $this->options = $this->activeField->calculateClientInputOption($this->options); $input = ActiveHtml::activeTextInput($this->model, $this->attribute, $this->options); } else { $input = Html::textInput($this->name, $this->value, $this->options); } if ($this->output === self::BASE64) { $src = $this->captcha->getDataUri(); } else { $src = Url::modify([$this->captchaAction, 'v' => uniqid()], Url::ABS); } $image = Html::img($src, $this->imageOptions); echo strtr($this->template, ['{input}' => $input, '{image}' => $image]); }
private function _calculateParts() { if (isset($this->parts['{input}']) && $this->parts['{input}'] === '') { return ''; } if (!isset($this->parts['{input}'])) { $this->inputOptions = $this->calculateClientInputOption($this->inputOptions); $this->parts['{input}'] = ActiveHtml::activeTextInput($this->model, $this->attribute, $this->inputOptions); } if (!isset($this->parts['{label}'])) { $this->parts['{label}'] = ActiveHtml::activeLabel($this->model, $this->attribute, $this->labelOptions); } if (!isset($this->parts['{error}'])) { $this->parts['{error}'] = $this->renderErrors(); } if (!isset($this->parts['{hint}'])) { $this->parts['{hint}'] = ActiveHtml::activeHint($this->model, $this->attribute, $this->hintOptions); } return strtr($this->template, $this->parts); }