Closed daavidkllr closed 5 years ago
Unable to reproduce. Tried to following code snipped with a corresponding content type containing an integer attribute.
$repository = $this->getContainer()->get('ezpublish.api.repository');
$locationService = $this->getContainer()->get('ezpublish.api.service.location');
$contentService = $this->getContainer()->get('ezpublish.api.service.content');
$contentTypeService = $this->getContainer()->get('ezpublish.api.service.content_type');
$testType = $contentTypeService->loadContentTypeByIdentifier('test');
$contentCreateStruct = $contentService->newContentCreateStruct($testType, 'eng-GB');
$locationCreateStruct = $locationService->newLocationCreateStruct(2);
$contentCreateStruct->setField('title', new TextLineValue('test-content'));
$contentCreateStruct->setField('relation', new Value([
new Value\Relation([
'contentId' => 52,
'attributes' => [
'integer_attribute' => new Integer(['value' => 123]),
],
])
]));
$repository->sudo(function () use ($contentService, $contentCreateStruct, $locationCreateStruct) {
$draft = $contentService->createContent($contentCreateStruct, [$locationCreateStruct]);
$contentService->publishVersion($draft->versionInfo);
});
Results in the new content being created beneath the content root node containing the expected value (linking to content#52
and containing 123
in integer_attribute
).
@daavidkllr Could you post the corresponding message contained in ContentFieldValidationException
?
Problem solved. It was my fault, the ERL validates correct. Issue can be closed.
Updating the content using the eZ Platform ContentService throws a ContentFieldValidationException.
Steps to reproduce:
Fails:
Works: