diff --git a/typo3/sysext/backend/Classes/Form/Container/PaletteAndSingleContainer.php b/typo3/sysext/backend/Classes/Form/Container/PaletteAndSingleContainer.php index 2e7daf9eb496f66ad0b6c6d045a2abfd9e9f3e70..43af13dfae6410b01d7632980ca25abb7ad5aaf4 100644 --- a/typo3/sysext/backend/Classes/Form/Container/PaletteAndSingleContainer.php +++ b/typo3/sysext/backend/Classes/Form/Container/PaletteAndSingleContainer.php @@ -15,6 +15,7 @@ namespace TYPO3\CMS\Backend\Form\Container; */ use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -377,6 +378,10 @@ class PaletteAndSingleContainer extends AbstractContainer $label = BackendUtility::wrapInHelp($this->data['tableName'], $fieldName, htmlspecialchars($element['fieldLabel'])); + if ($GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] && $this->getBackendUser()->isAdmin()) { + $label .= '<code>[' . htmlspecialchars($fieldName) . ']</code>'; + } + $content = []; $content[] = '<div class="' . implode(' ', $paletteFieldClasses) . '">'; $content[] = '<label class="t3js-formengine-label">'; @@ -413,4 +418,14 @@ class PaletteAndSingleContainer extends AbstractContainer { return $GLOBALS['LANG']; } + + /** + * Returns the current BE user. + * + * @return BackendUserAuthentication + */ + protected function getBackendUser() + { + return $GLOBALS['BE_USER']; + } } diff --git a/typo3/sysext/backend/Tests/Unit/Form/Container/PaletteAndSingleContainerTest.php b/typo3/sysext/backend/Tests/Unit/Form/Container/PaletteAndSingleContainerTest.php index 778eb29adcc5e8206599056da13d413ce722196b..430feeaaa2ad84e5dd5c6c0bf0ade7c5adb29271 100644 --- a/typo3/sysext/backend/Tests/Unit/Form/Container/PaletteAndSingleContainerTest.php +++ b/typo3/sysext/backend/Tests/Unit/Form/Container/PaletteAndSingleContainerTest.php @@ -19,6 +19,7 @@ use Prophecy\Argument; use TYPO3\CMS\Backend\Form\Container\PaletteAndSingleContainer; use TYPO3\CMS\Backend\Form\Container\SingleFieldContainer; use TYPO3\CMS\Backend\Form\NodeFactory; +use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -66,6 +67,8 @@ class PaletteAndSingleContainerTest extends UnitTestCase $languageService = $this->prophesize(LanguageService::class); $GLOBALS['LANG'] = $languageService->reveal(); + $backendUserAuthentication = $this->prophesize(BackendUserAuthentication::class); + $GLOBALS['BE_USER'] = $backendUserAuthentication->reveal(); $languageService->loadSingleTableDescription(Argument::cetera())->willReturn(''); // Expect translation call to the label reference @@ -121,6 +124,8 @@ class PaletteAndSingleContainerTest extends UnitTestCase $languageService = $this->prophesize(LanguageService::class); $GLOBALS['LANG'] = $languageService->reveal(); + $backendUserAuthentication = $this->prophesize(BackendUserAuthentication::class); + $GLOBALS['BE_USER'] = $backendUserAuthentication->reveal(); $languageService->loadSingleTableDescription(Argument::cetera())->willReturn(''); // Expect translation call to the label reference @@ -177,6 +182,8 @@ class PaletteAndSingleContainerTest extends UnitTestCase $languageService = $this->prophesize(LanguageService::class); $GLOBALS['LANG'] = $languageService->reveal(); + $backendUserAuthentication = $this->prophesize(BackendUserAuthentication::class); + $GLOBALS['BE_USER'] = $backendUserAuthentication->reveal(); $languageService->loadSingleTableDescription(Argument::cetera())->willReturn(''); // Expect translation call to the label reference diff --git a/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml b/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml index 37b71744e6b81912206fc59181f6f474128c03db..fbd48ad5a3d4b57047db19677b59bec6e02aaedd 100644 --- a/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml +++ b/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml @@ -334,7 +334,7 @@ BE: <p>If disabled the last modification date of the file will be appended as a query-string.</p> debug: type: bool - description: 'If enabled, the loginrefresh is disabled and pageRenderer is set to debug mode. Use this to debug the backend only!' + description: 'If enabled, the loginrefresh is disabled and pageRenderer is set to debug mode. Furthermore the fieldname is prepended to the label of fields. Use this to debug the backend only!' FE: type: container items: diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-83461-ShowFieldnameNextToTitleInDebugMode.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-83461-ShowFieldnameNextToTitleInDebugMode.rst new file mode 100644 index 0000000000000000000000000000000000000000..8be1f665c408d522ffc332db7c8641d284053edc --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-83461-ShowFieldnameNextToTitleInDebugMode.rst @@ -0,0 +1,22 @@ +.. include:: ../../Includes.txt + +============================================================ +Feature: #83461 - Show fieldname next to title in debug mode +============================================================ + +See :issue:`83461` + +Description +=========== + +If the configuration `['BE']['debug']` is enabled and the current user is an administrator, the fieldname is prepended to the title of each field generated by the `FormEngine`. + + +Impact +====== + +The correct name of a field is important to know for developers and integrators. Examples are setting up access permissions or configuration using TsConfig. + +Instead of looking into the source code of the browser, it is now enough to enable the debug mode for the backend. + +.. index:: Backend, NotScanned