code: protected function addErrorClassIfNeeded(&$options)
      {
          // Get proper attribute name when attribute name is tabular.
          $attributeName = Html::getAttributeName($this->attribute);
  
          if ($this->model->hasErrors($attributeName)) {
              Html::addCssClass($options, $this->form->errorCssClass);
          }
      }
docs: Adds validation class to the input options if needed.
  @param $options array input options
  @since 2.0.14