#62486PropertyMapping in Fluid via __type syntax
Description
Hey,
we have a domain model which contains a property “surveys” which contains a list of types of surveys. All childs are subclasses of the parent survey class
/**
* Surveys
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\VendorName\ExtensionName\Domain\Model\Survey>
*/
protected $surveys;
class OfdSurvey extends \VendorName\ExtensionName\Domain\Model\Survey {
}
class SvbSurvey extends \VendorName\ExtensionName\Domain\Model\Survey {
}
I want to create and modifiy the objects within the list directly via fluid. So i put this code into my model, controller and view:
Domain Model:
class Survey extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
...
/**
* @return string
*/
public function getClass() {
return get_class($this);
}
...
}
Controller:
public function initializeTestAction() {
$propertyMappingConfiguration->forProperty('affiliation.surveys.*')->allowAllProperties();
$propertyMappingConfiguration->forProperty('affiliation.surveys.*')->allowCreationForSubProperty('*');
$propertyMappingConfiguration->forProperty('affiliation.surveys.*')->setTypeConverterOption(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter',
PersistentObjectConverter::CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED,
TRUE
);
$propertyMappingConfiguration->forProperty('affiliation.surveys.*')->setTypeConverterOption(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter',
PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED,
TRUE
);
$propertyMappingConfiguration->forProperty('affiliation.surveys.*')->setTypeConverterOption(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter',
PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED,
TRUE
);
}
public function testAction() {
...
$surveyTypes = array(
'VendorName\ExtensionName\Domain\Model\Survey\OfdSurvey' => 'OFD'),
'VendorName\ExtensionName\Domain\Model\Survey\SvbSurvey' => 'SVB')
);
...
$this->view->assign('surveyTypes', $surveyTypes);
}
View:
<f:for each="{affiliationForm.affiliation.surveys}" as="survey" iteration="surveyIterator">
<f:form.select class="affiliation-survey-type" id="affiliation-survey-type-{surveyIterator.index}" property="affiliation.surveys.{surveyIterator.index}.__type" value="{survey.class}" options="{surveyTypes}"></f:form.select>
</f:form>
When i select another type to change the type of the survey and submit the form i get the following error:
#1297759968: Exception while property mapping at property path "affiliation.surveys.0":Object with identity "18" not found.
But the object with the identity 18 still exists in the database. When i dont change the type (only another property) everything works fine.
I think the PropertyMapper works incorrect when you want to use type modification, when the object is already persisted.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.