[BUGFIX] Show record title for inline element 26/51626/2
authorNicole Cordes <typo3@cordes.co>
Wed, 4 Jan 2017 14:06:38 +0000 (15:06 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 10 Feb 2017 19:14:20 +0000 (20:14 +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/51626
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaRecordTitle.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaRecordTitleTest.php

index ca9d44a..f31d0ce 100644 (file)
@@ -159,7 +159,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;
@@ -205,6 +206,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 4a04aca..5db0abf 100644 (file)
@@ -617,6 +617,42 @@ class TcaRecordTitleTest extends UnitTestCase
     }
 
     /**
+     * @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)