Reputation: 1274
When calling getter on AbstractValueObject object this error is shown:
Exception while property mapping at property path "":Creation of objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_CREATION_ALLOWED" to TRUE
How to resolve this?
Upvotes: 2
Views: 7223
Reputation: 422
I just found a solution to this issue without discarding ValueObject type: In the form viewhelper, one has to handover explicitly the UID of the AbstractValueObject:
I.e.
<f:for each="{colors}" as="color">
<f:form.radio property="color" value="{color.uid}" />
</f:for>
in place of <f:form.radio property="color" value="{color}" />
, where {colors} is an array of AbstractValueObject.
The reason can be found in here: https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/extbase/Classes/Property/TypeConverter/PersistentObjectConverter.php
The annotation in the header says:
- If the input is string, it is assumed to be a UID. Then, the object is fetched from persistence.
- ...
- If the input has NO identity property, but additional properties, we create a new object and return it.
A ValueObject has no identity by definition. So the only way to add it without creating a new one is by passing the UID to the property mapper as a string parameter.
Upvotes: 0
Reputation: 1274
In Your extension builder, model shoud be selected as Entity instead of Value Object. Or in model class change class definition to extend AbstractEntity instead of AbstractValueObject
# change this line:
class MyClass extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
# into this line:
class MyClass extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
Upvotes: 1