--- a/typo3/sysext/backend/Classes/Controller/Wizard/AddController.php 2018-07-12 14:01:26.000000000 +0300
+++ b/typo3/sysext/backend/Classes/Controller/Wizard/AddController.php 2018-08-03 12:25:29.000000000 +0300
@@ -235,27 +235,41 @@
// values after the wizard falls back to the parent record
$currentValue = $currentParentRow[$this->P['field']];
if (is_array($currentValue)) {
- $currentValue = implode(',', array_column($currentValue, 'uid'));
+ $firstValue = reset($currentValue);
+ if (is_array($firstValue) && isset($firstValue['uid'])) {
+ $currentValue = array_column($currentValue, 'uid');
+ }
}
+
+ // Normalize CSV values
+ if (!is_array($currentValue)) {
+ $currentValue = GeneralUtility::trimExplode(',', $currentValue, true);
+ }
+
+ // Normalize all items to "
_" format
+ $currentValue = array_map(function ($item) {
+ // Handle per-item table for "group" elements
+ if (is_array($item)) {
+ $item = $item['table'] . '_' . $item['uid'];
+ } else {
+ $item = $this->table . '_' . $item;
+ }
+
+ return $item;
+ }, $currentValue);
+
switch ((string)$this->P['params']['setValue']) {
case 'set':
- $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $recordId;
+ $currentValue = [$recordId];
break;
case 'prepend':
- $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $currentValue . ',' . $recordId;
+ $currentValue[] = $recordId;
break;
case 'append':
- $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $recordId . ',' . $currentValue;
+ array_unshift($currentValue, $recordId);
break;
}
- $data[$this->P['table']][$this->P['uid']][$this->P['field']] = implode(
- ',',
- GeneralUtility::trimExplode(
- ',',
- $data[$this->P['table']][$this->P['uid']][$this->P['field']],
- true
- )
- );
+ $data[$this->P['table']][$this->P['uid']][$this->P['field']] = implode(',', $currentValue);
}
// Submit the data:
$dataHandler->start($data, []);