/**
* {@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);
}