Project

General

Profile

Actions

Bug #54490

closed

Overriding tcaTree configuration results in missing foreign_table error

Added by Stefan Froemken almost 11 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
Start date:
2013-12-18
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.4
Tags:
Complexity:
medium
Is Regression:
No
Sprint Focus:

Description

Hello Core-Team,

I have following TCA-Configuration:

<T3DataStructure>
    <meta>
        <langDisable>1</langDisable>
    </meta>
    <sheets>
        <sDEFAULT>
            <ROOT>
                <TCEforms>
                    <sheetTitle>LLL:EXT:events2/Resources/Private/Language/FlexForms.xlf:sheetGeneral</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <ageGroup>
                        <TCEforms>
                            <label>LLL:EXT:events2/Resources/Private/Language/FlexForms.xlf:categories</label>
                            <config>
                                <type>select</type>
                                <foreign_table>sys_category</foreign_table>
                                <renderMode>tree</renderMode>
                                <treeConfig>
                                    <parentField>parent</parentField>
                                    <rootUid>0</rootUid>
                                    <appearance>
                                        <showHeader>TRUE</showHeader>
                                        <expandAll>FALSE</expandAll>
                                    </appearance>
                                </treeConfig>
                                <size>15</size>
                                <maxitems>1</maxitems>
                                <minitems>0</minitems>
                            </config>
                        </TCEforms>
                    </ageGroup>
                </el>
            </ROOT>
        </sDEFAULT>
    </sheets>
</T3DataStructure>

This works perfect. All my categories will be displayed. But in case of many categories it would be good to reduce this selection. So I add this row to pageTSconfig:

TCEFORM.tt_content.pi_flexform.events2_culture.sDEFAULT.ageGroup.config.treeConfig.rootUid = 4

On opening my Plugin with this Flexform I get this error now:

TCA Tree configuration is invalid: "foreign_table" not set

Stefan

Actions #1

Updated by Stefan Froemken almost 11 years ago

In modifySingleFlexFormSheet you have this condition on line 173:

if (empty($sheetConf[$fieldName]) || !is_array($sheetConf[$fieldName])) {
    continue;
}

If no pageTSconfig for this field is set it breaks here. That's why it works.

But if any value is set in pageTSconfig it first tries to get all items with addSelectOptionsToItemArray on line 199 and executes all these properties for addItems, removeItems, renameItems AND very importent you DELETE all properties which regard to DB-Properties like foreign_table, foreign_table_where and many many more.

I'm wondering about this, because later on in this process you call getSingleField_typeFlex_draw() which checks for is_array($value['TCEforms']['config']) and calls getSingleField_SW() and then getSingleField_typeSelect(). Now the same procedure as above starts again: getSelectItems() calls addSelectOptionsToItemArray(), but now the item collection breaks, because you have removed all DB-Properties. And this results in "TCA Tree configuration is invalid: "foreign_table" not set".

Solution:
- Remove everything after row 193 till method-end in FlexFormsHelper.php

Stefan

Actions #2

Updated by Christoph Buchli over 10 years ago

I can confirm the buggy behaviour described in this issue.

Actions #3

Updated by Gerrit Code Review over 10 years ago

  • Status changed from New 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 http://review.typo3.org/31965

Actions #4

Updated by Stefan Froemken over 10 years ago

You can use following workaround (Hook):

In ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'][] = 'JWeiland\\Events2\\Hooks\\ModifyTcaOfCategoryTrees';

Then something like that in your hook-file:

public function getSingleField_beforeRender($table, $field, $row, &$PA) {
    // check if a FlexForm was rendered
    if ($table === 'tt_content' && $field === 'pi_flexform') {
        // check, if TCA configuration exists
        if (isset($PA['fieldConf']) && is_array($PA['fieldConf']) && isset($PA['fieldConf']['config']) && is_array($PA['fieldConf']['config'])) {
            // check, if we have TCA-type "select" defined and it is configured as "tree" 
            if (isset($PA['fieldConf']['config']['type']) && $PA['fieldConf']['config']['type'] === 'select' && isset($PA['fieldConf']['config']['renderMode']) && $PA['fieldConf']['config']['renderMode'] === 'tree') {
                $PA['fieldConf']['config']['treeConfig']['rootUid'] = (int)$this->extConf->getRootUid();
            }
        }
    }
}
Actions #5

Updated by Gerrit Code Review about 10 years ago

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/32643

Actions #6

Updated by Stefan Froemken about 10 years ago

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

Updated by Riccardo De Contardi about 7 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF