Decimal field causes error message on custom entity

Created on 3 December 2024, 1 day ago

Problem/Motivation

We have a custom entity with a decimal field and that seems to cause an error in ListDataDefinitionNormalizer.php.

Steps to reproduce

Create a custom entity with following BaseFieldDefinition:

$fields['test'] = BaseFieldDefinition::create('decimal')
      ->setRequired(FALSE)
      ->setRevisionable(TRUE)
      ->setSetting('precision', 12)
      ->setSetting('scale', 2)
      ->setLabel('test');

Go to the Schema page and you should see an error like:
TypeError: Symfony\Component\Serializer\Serializer::normalize(): Return value must be of type ArrayObject|array|string|int|float|bool|null, stdClass returned in Symfony\Component\Serializer\Serializer

I hunted it down to this line here in ComplexDataDefinitionNormalizer.php:

$normalized = $this->extractPropertyData($entity);

$normalized contains a key "value" which is a StdClass object. Other field types don't seem to have that key there. I hope that helps.

🐛 Bug report
Status

Active

Component

Code

Created by

🇦🇺Australia Stefan Lehmann

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024