yii\widgets\ActiveField::error PHP Method

error() public method

Note that even if there is no validation error, this method will still return an empty error tag.
public error ( array | false $options = [] )
$options array | false 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 this parameter is `false`, no error tag will be rendered. The following options are specially handled: - `tag`: this specifies the tag name. If not set, `div` will be used. See also [[\yii\helpers\Html::tag()]]. If you set a custom `id` for the error element, you may need to adjust the [[$selectors]] accordingly.
    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;
    }