/** * @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(); } }
/** * Generates a tag that contains the first validation error of [[attribute]]. * Note that even if there is no validation error, this method will still return an empty error tag. * @param array|boolean $options the tag options in terms of name-value pairs. It will be merged with [[errorOptions]]. * The options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded * using [[Html::encode()]]. If a value is null, the corresponding attribute will not be rendered. * * The following options are specially handled: * * - tag: this specifies the tag name. If not set, "div" will be used. * * If this parameter is false, no error tag will be rendered. * * If you set a custom `id` for the error element, you may need to adjust the [[$selectors]] accordingly. * * @return $this the field object itself */ public function error($options = []) { if ($options === false) { $this->parts['{error}'] = ''; return $this; } $options = array_merge($this->errorOptions, $options); $this->parts['{error}'] = Html::error($this->model, $this->attribute, $options); return $this; }