[BUGFIX] Show record title for inline element 15/51115/2
authorNicole Cordes <typo3@cordes.co>
Wed, 4 Jan 2017 14:06:38 +0000 (15:06 +0100)
committerHelmut Hummel <typo3@helhum.io>
Fri, 10 Feb 2017 11:51:49 +0000 (12:51 +0100)
Currently no record titles for nested inline elements are shown. Due to
the current method to resolve a record title for an inline element
always an empty title is returned as there is the same processing as for
select fields. This patch introduces an own resolving method according to
the already resolved children attached to the current field.

Resolves: #78726
Releases: master, 7.6
Change-Id: I7f62ad843552534b36c0ccd91488c79ff796ec0c
Reviewed-on: https://review.typo3.org/51115
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Josef Glatz <josef.glatz@typo3.org>
Tested-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Tested-by: Helmut Hummel <typo3@helhum.io>
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaRecordTitle.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaRecordTitleTest.php

index 6bcace6..c2bdf41 100644 (file)
@@ -158,7 +158,8 @@ class TcaRecordTitle implements FormDataProviderInterface
                 $recordTitle = $this->getRecordTitleForRadioType($rawValue, $fieldConfig);
                 break;
             case 'inline':
-                // intentional fall-through
+                $recordTitle = $this->getRecordTitleForInlineType($rawValue, $result['processedTca']['columns'][$fieldName]['children']);
+                break;
             case 'select':
                 $recordTitle = $this->getRecordTitleForSelectType($rawValue, $fieldConfig);
                 break;
@@ -204,6 +205,23 @@ class TcaRecordTitle implements FormDataProviderInterface
     }
 
     /**
+     * @param int $value
+     * @param array $children
+     *
+     * @return string
+     */
+    protected function getRecordTitleForInlineType($value, array $children)
+    {
+        foreach ($children as $child) {
+            if ((int)$value === $child['vanillaUid']) {
+                return $child['recordTitle'];
+            }
+        }
+
+        return '';
+    }
+
+    /**
      * Return the record title for database records
      *
      * @param mixed $value Current database value of this field
index 75fa609..96c6588 100644 (file)
@@ -617,6 +617,42 @@ class TcaRecordTitleTest extends \TYPO3\Components\TestingFramework\Core\Unit\Un
     }
 
     /**
+     * @test
+     */
+    public function addDataReturnsRecordTitleForInlineType()
+    {
+        $input = [
+            'tableName' => 'aTable',
+            'databaseRow' => [
+                'uid' => '1',
+                'aField' => '2',
+            ],
+            'processedTca' => [
+                'ctrl' => [
+                    'label' => 'aField'
+                ],
+                'columns' => [
+                    'aField' => [
+                        'config' => [
+                            'type' => 'inline'
+                        ],
+                        'children' => [
+                            [
+                                'recordTitle' => 'foo',
+                                'vanillaUid' => 2
+                            ]
+                        ]
+                    ]
+                ],
+            ]
+        ];
+
+        $expected = $input;
+        $expected['recordTitle'] = 'foo';
+        $this->assertSame($expected, $this->subject->addData($input));
+    }
+
+    /**
      * Data provider for addDataReturnsRecordTitleForGroupType
      * Each data set is an array with the following elements:
      *  - TCA field configuration (merged with base config)