Hallo zusammen,
ich habe eine n:m Relation mit Kategorien, klappt im Backend auch wunderbar. Allerdings muss es dies auch im Frontend tun. Beim "Speichern" (ob create oder update) erhalte ich immer den Fehler
"Exception while property mapping at property path "cat":It is not allowed to map property "0"."
Kann mir hier jemand weiterhelfen? Das Fluid Template beinhaltet ein Select-Feld, es muss eine Mehrfachauswahl möglich sein
<f:form.select property="cat" multiple="multiple">
Auch mit hiddenfields funktioniert es nicht (...name="tx_myext_plugin[object][cat][]" - schon versucht). Im Backend geht das ganze (wie schon gesagt) ohne Probleme, dort kann ich mehrere Relationen zu einem Datensatz speichern. Model, Controller und TCA wurden mit dem Extension Manager erstellt.
Besten Dank schon mal vorab!
Du musst alle subproperties explizit erlauben. Das ganze kannst Du mit einer initializeCreateAction Funktion machen. hier mal ein grobes beispiel. "project" ist das Hauptobjekt, "branch" und "documents" sind jeweils mutliple relationen:
/**
* action initializeCreate
*
*/
public function initializeCreateAction(){
if($this->request->hasArgument('project')) {
$project = $this->request->getArgument('project');
$propertyMappingConfiguration = $this->arguments->getArgument('project')->getPropertyMappingConfiguration();
$propertyMappingConfiguration->allowProperties('branch');
if(!empty($project['branch'])) {
$propertyMappingConfiguration->forProperty('branch')->allowAllProperties();
$propertyMappingConfiguration->allowModificationForSubProperty('branch');
foreach($project['branch'] as $branchIndex => $branchPropertyArray) {
$propertyPath = 'branch.' . $branchIndex;
$propertyMappingConfiguration->forProperty($propertyPath)->allowAllProperties();
$propertyMappingConfiguration->allowCreationForSubProperty($propertyPath);
$propertyMappingConfiguration->allowModificationForSubProperty($propertyPath);
} // end foreach
} // end if(!empty)
$propertyMappingConfiguration->allowProperties('documents');
if(!empty($project['documents'])) {
$propertyMappingConfiguration->forProperty('documents')->allowAllProperties();
$propertyMappingConfiguration->allowModificationForSubProperty('documents');
foreach($project['documents'] as $documentIndex => $documentPropertyArray) {
$propertyPath = 'documents.' . $documentIndex;
$propertyMappingConfiguration->forProperty($propertyPath)->allowAllProperties();
$propertyMappingConfiguration->allowCreationForSubProperty($propertyPath);
$propertyMappingConfiguration->allowModificationForSubProperty($propertyPath);
} // end foreach
} // end if(!empty)
} // end if(request->hasArgument)
}
Hier nochmal als pastebin, die Codeformatierung hier ist ziemlich beengt 😃
http://pastebin.com/xS43s6k8