intenseprogramming / enhanced-relationlist-type-bundle

This bundle contains the enhanced relation list field type for eZ Platform version 2.x
MIT License
4 stars 1 forks source link

Content fields did not validate #10

Closed daavidkllr closed 5 years ago

daavidkllr commented 5 years ago

Updating the content using the eZ Platform ContentService throws a ContentFieldValidationException.

Steps to reproduce:

Fails:

$relations[] = new EnhancedRelationListValue\Relation([
    'contentId'  => $relationContentId,
    'attributes' => [
        'submenu_element_limit' => new Integer(['value' => 1])
    ]
]);

Works:

$relations[] = new EnhancedRelationListValue\Relation([
    'contentId'  => $relationContentId,
    'attributes' => [
        'submenu_element_limit' => new TextLine(['value' => 1])
    ]
]);
skonrad commented 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?

dkllr commented 5 years ago

Problem solved. It was my fault, the ERL validates correct. Issue can be closed.