From 67ad19388584a8b33b6bd7351d8157d2f22660a0 Mon Sep 17 00:00:00 2001 From: Ivan Ternovtsiy Date: Tue, 6 Oct 2020 17:10:37 +0300 Subject: [PATCH] EZP-31954: fix fatal error when no error target defined (#34) --- src/lib/Validator/Constraints/FieldValueValidator.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/Validator/Constraints/FieldValueValidator.php b/src/lib/Validator/Constraints/FieldValueValidator.php index 93289282..6e69b66b 100644 --- a/src/lib/Validator/Constraints/FieldValueValidator.php +++ b/src/lib/Validator/Constraints/FieldValueValidator.php @@ -13,8 +13,8 @@ use eZ\Publish\Core\FieldType\ValidationError; use eZ\Publish\SPI\FieldType\Value; use EzSystems\EzPlatformContentForms\Data\Content\FieldData; -use Symfony\Component\Validator\Util\PropertyPath; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Util\PropertyPath; /** * Base class for field value validators. @@ -89,6 +89,10 @@ protected function getFieldTypeIdentifier(ValueObject $value): string protected function generatePropertyPath($errorIndex, $errorTarget): string { - return PropertyPath::append('value', $errorTarget); + $basePath = 'value'; + + return $errorTarget === null + ? $basePath + : PropertyPath::append($basePath, $errorTarget); } }