/** * @param AbstractField|Group|Fieldset $element * * @return void */ private function addErrorClass($element) { if ($element instanceof Group || $element instanceof Fieldset) { foreach ($element->getFields() as $field) { if ($element instanceof Group || $element instanceof Fieldset) { $this->addErrorClass($field); } elseif ($field->isRequired()) { $field->addClass('has-error'); } } } elseif ($element->isRequired()) { $element->addClass('has-error'); } }