Beispiel #1
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]);
 }
Beispiel #2
0
 /**
  * @inheritdoc
  */
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'has-error');
             $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterInputOptions);
             return Html::activeDropDownList($model, $this->attribute, $this->filter, $options) . $error;
         } else {
             return Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error;
         }
     } else {
         return parent::renderFilterCellContent();
     }
 }
 /**
  * Renders a text input.
  * This method will generate the "name" and "value" tag attributes automatically for the model attribute
  * unless they are explicitly specified in `$options`.
  * @param array $options the tag options in terms of name-value pairs. These will be rendered as
  * the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]].
  *
  * The following special options are recognized:
  *
  * - maxlength: integer|boolean, when `maxlength` is set true and the model attribute is validated
  *   by a string validator, the `maxlength` option will take the value of [[\Leaps\Validator\StringValidator::max]].
  *   This is available since version 2.0.3.
  *
  * Note that if you set a custom `id` for the input element, you may need to adjust the value of [[selectors]] accordingly.
  *
  * @return $this the field object itself
  */
 public function textInput($options = [])
 {
     $options = array_merge($this->inputOptions, $options);
     $this->adjustLabelFor($options);
     $this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $options);
     return $this;
 }