Project

General

Profile

Actions

Bug #102366

closed

Hardcoded type check in ElementBrowser.php prevents class extensions

Added by Michael Stopp about 1 year ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2023-11-13
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Since the TCA field type folder doesn't support 'l10n_display' => 'defaultAsReadonly' (which it really shoud!), we decided to define our own form field type to check for the language and set readonly to true, if not in the default language. We defined a TCA field with a config section like this:

'config' => [
    'type' => 'user',
    'renderType' => 'uploadFolderField',
    'maxitems' => 1,
    'size' => 1,
],

We then defined the class for the new renderType something like this:

class UploadFolderElement extends \TYPO3\CMS\Backend\Form\Element\FolderElement
{
    public function render()
    {
        // -> add own functionality
        return parent::render();
    }
}

This will result in a "Field controls must return a title" exception thrown in \TYPO3\CMS\Backend\Form\NodeExpansion\FieldControl.
After some digging and debugging it turns out that this is caused by a type check in \TYPO3\CMS\Backend\Form\FieldControl\ElementBrowser:

$title = '';
if ($type === 'group') {
    $title = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.browse_db';
} elseif ($type === 'folder') {
    $title = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.browse_folder';
}

Since the type will be user in our example, you will always run into this exception. Only allowing group and folder as valid types basically prevents extensions of form fields that use the element browser.

There should either be a sensible default for $title or a way to define an alternative title via TCA.

BTW, as a workaround you can force the type back to one of the allowed values before calling the parent's render method:

$this->data['parameterArray']['fieldConf']['config']['type'] = 'folder';

But that's not really the idea of class extensions, is it?

Actions #1

Updated by Gerrit Code Review about 1 year ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81746

Actions #2

Updated by Gerrit Code Review about 1 year ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81746

Actions #3

Updated by Oliver Bartsch about 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #4

Updated by Gerrit Code Review about 1 year ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81767

Actions #5

Updated by Oliver Bartsch about 1 year ago

  • Status changed from Under Review to Resolved
Actions #6

Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF