Project

General

Profile

Actions

Bug #78726

closed

Nested IRRE fields do not resolve recordTitle

Added by Klaus Bitto about 8 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2016-11-16
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.6
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Hi!

I have a record table 'subcategories' with 'inline' field (MM) 'questions'.

The record table 'questions' has an 'inline' field (uid - n:1 mapping) 'question_content' for a single text tt_content element.

The 'questions' ctrl=>label is 'question_content'.

In List view, each questions get the record title for the question record loaded from the question_content field: The UID stored in question_content resolves to a tt_content record, and the label_alt=bodytext configuration makes sure that in pure list view, the tt_content element's bodytext is used for the question record label.

But: When the question is shown as IRRE field, this does not work. Then, the recordTitle is empty ('[no title]').

Expected: Also when in IRRE, the question's question_content element's bodytext should be used for the question's record label, as it is when listing question records in list view.

--> When a record uses an own inline field for its label, then no label will be shown if the record ITSELF is shown as inline child.

Actions #1

Updated by Klaus Bitto about 8 years ago

As a temporary workaround, this formattedLabel_userFunc works:

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class NestedInlineFieldLabelProvider {

    /**
     * While a record can have a nested inline field value as label (the first child's record title
     * will become the label), this functionality does not work when the record itself is shown as inline child.
     * We need to use a userFunc to work around this issue. (https://forge.typo3.org/issues/78726)
     *
     * @param array &$parameters
     */
    function nestedInlineFieldFormattedLabelUserFunc(&$parameters) {
        if(!$parameters['row']) {
            return;
        }

        $enclosingTableTCA = $GLOBALS['TCA'][$parameters['table']];

        $labelField = $enclosingTableTCA['ctrl']['label'];
        $labelFieldForeignTable = $enclosingTableTCA['columns'][$labelField]['config']['foreign_table'];

        // Note: \TYPO3\CMS\Backend\Form\FormDataProvider\TcaInline::resolveRelatedRecords() resolves
        // $result['databaseRow'][$fieldName] into a comma-separated UID list.
        // Unfortunately, $result['processedTca']['columns'][$fieldName]['children'] is not available to us here.
        // @see \TYPO3\CMS\Backend\Form\FormDataProvider\TcaInline::resolveRelatedRecords()

        $labelFieldForeignUidCsvList = $parameters['row'][$labelField];
        if(!$labelFieldForeignUidCsvList) {
            return;
        }

        $labelFieldForeignUid = (int)current(
            GeneralUtility::trimExplode(',', $labelFieldForeignUidCsvList, true)
        );
        if(!$labelFieldForeignUid) {
            return;
        }

        $parameters['title'] = BackendUtility::getRecordTitle(
            $labelFieldForeignTable,
            BackendUtility::getRecord(
                $labelFieldForeignTable,
                $labelFieldForeignUid
            ),
            true
        );
    }
}

Relevant ctrl definition of 'tx_ncappomfbpscan_domain_model_question':

    'ctrl' => [
        'label' => 'question_content',
        'formattedLabel_userFunc' => 'Netcreators\NcAppoMfbpscan\TYPO3\Service\TCA\NestedInlineFieldLabelProvider->nestedInlineFieldFormattedLabelUserFunc',
        ...
    ],

--> Without the 'formattedLabel_userFunc', the label (question_content[first child record].header+bodytext) is shown in list view, but not shown when question is an inline child of the enclosing subcategory (TCA column definition: see below.)

Column definition of 'tx_ncappomfbpscan_domain_model_question'.'question_content':

        'question_content' => [
            'exclude' => 0,
            'label' => 'LLL:EXT:nc_appo_mfbpscan/Resources/Private/Language/locallang_db.xlf:tx_ncappomfbpscan_domain_model_question.question_content',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tt_content',
                'MM' => 'tx_ncappomfbpscan_question_content_mm',
                'MM_match_fields' => [
                    'fieldname' => 'question_content',
                ],
                'maxitems' => 9999,
                'appearance' => [
                    'collapseAll' => true,
                    'levelLinksPosition' => 'top',
                    'showSynchronizationLink' => 1,
                    'showPossibleLocalizationRecords' => 1,
                    'useSortable' => 1,
                    'showAllLocalizationLink' => 1
                ],
                'foreign_types' => [
                    'text' => [
                        'columnsOverrides' => [
                            'bodytext' => [
                                'defaultExtras' => 'richtext:rte_transform[mode=ts_css]',
                            ],
                        ],
                        'showitem' => 'bodytext;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:bodytext_formlabel',
                    ],
                ],
            ],
        ],

Column definition of enclosing 'tx_ncappomfbpscan_domain_model_subcategory'.'questions':

        'questions' => [
            'exclude' => 0,
            'label' => 'LLL:EXT:nc_appo_mfbpscan/Resources/Private/Language/locallang_db.xlf:tx_ncappomfbpscan_domain_model_subcategory.questions',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tx_ncappomfbpscan_domain_model_question',
                'foreign_field' => 'subcategory',
                'foreign_sortby' => 'sorting',
                'maxitems' => 9999,
                'appearance' => [
                    'collapseAll' => true,
                    'levelLinksPosition' => 'top',
                    'showSynchronizationLink' => 1,
                    'showPossibleLocalizationRecords' => 1,
                    'useSortable' => 1,
                    'showAllLocalizationLink' => 1
                ],
            ],
        ],
Actions #2

Updated by Nicole Cordes almost 8 years ago

  • Status changed from New to Accepted
  • Assignee set to Nicole Cordes
Actions #3

Updated by Gerrit Code Review almost 8 years ago

  • Status changed from Accepted to Under Review

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

Actions #4

Updated by Gerrit Code Review almost 8 years ago

Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51625

Actions #5

Updated by Gerrit Code Review almost 8 years ago

Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51626

Actions #6

Updated by Nicole Cordes almost 8 years ago

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

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF