/** * {@inheritDoc} */ public function addError(Error $error, PropertyPathIterator $pathIterator = null) { if (null !== $pathIterator) { if ($error instanceof FieldError && $pathIterator->hasNext()) { $pathIterator->next(); if ($pathIterator->isProperty() && $pathIterator->current() === 'fields') { $pathIterator->next(); } if ($this->has($pathIterator->current()) && !$this->get($pathIterator->current())->isHidden()) { $this->get($pathIterator->current())->addError($error, $pathIterator); return; } } else { if ($error instanceof DataError) { $iterator = new RecursiveFieldIterator($this); $iterator = new \RecursiveIteratorIterator($iterator); foreach ($iterator as $field) { if (null !== ($fieldPath = $field->getPropertyPath())) { if ($fieldPath->getElement(0) === $pathIterator->current() && !$field->isHidden()) { if ($pathIterator->hasNext()) { $pathIterator->next(); } $field->addError($error, $pathIterator); return; } } } } } } parent::addError($error); }
/** * {@inheritDoc} */ public function addError(FieldError $error, PropertyPathIterator $pathIterator = null, $type = null) { if ($pathIterator !== null) { if ($type === self::FIELD_ERROR && $pathIterator->hasNext()) { $pathIterator->next(); if ($pathIterator->isProperty() && $pathIterator->current() === 'fields') { $pathIterator->next(); } if ($this->has($pathIterator->current()) && !$this->get($pathIterator->current())->isHidden()) { $this->get($pathIterator->current())->addError($error, $pathIterator, $type); return; } } else { if ($type === self::DATA_ERROR) { $iterator = new RecursiveFieldsWithPropertyPathIterator($this); $iterator = new \RecursiveIteratorIterator($iterator); foreach ($iterator as $field) { if (null !== ($fieldPath = $field->getPropertyPath())) { if ($fieldPath->getElement(0) === $pathIterator->current() && !$field->isHidden()) { if ($pathIterator->hasNext()) { $pathIterator->next(); } $field->addError($error, $pathIterator, $type); return; } } } } } } parent::addError($error); }