Beispiel #1
0
 /**
  * Formats the value as an image tag.
  * @param mixed $value the value to be formatted.
  * @param array $options the tag options in terms of name-value pairs. See [[Html::img()]].
  * @return string the formatted result.
  */
 public function asImage($value, $options = [])
 {
     if ($value === null) {
         return $this->nullDisplay;
     }
     return Html::img($value, $options);
 }
Beispiel #2
0
 /**
  * Renders the widget.
  */
 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]);
 }