Bug #87569

itemsProcFunc in TCA in combination with used table not working correct

Added by Martin Weymayer 6 months ago. Updated 2 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2019-01-29
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Steps zu reproduce:
- make extension f.e. products where you add mm relation for categories
- also add mm relation for "similar products" which is connected to products table
- add itemsProcFunc for "similar products" like:

'config' => array(
                'type' => 'select',
                'renderType' => 'selectMultipleSideBySide',
                #'multiple' => 1,
                'foreign_table' => 'tx_produktdatenbank_domain_model_produkte',
                'MM' => 'tx_produktdatenbank_produkte_produkte_mm',
                'foreign_table_where' => 'ORDER BY title ASC ',
                'itemsProcFunc' => 'tx_produktdatenbank_flexform->extendedItemAehnlicheprodukte',
                'size' => '20',
                'autosizemax' => '20',
                'maxitems' => '99',
                'minitems' => '0'
            ),

and in extendedItemAehnlicheprodukte function:

$table = 'tx_produktdatenbank_domain_model_categories';
        $where = '1=1 ' . BackendUtility::BEenableFields ($table) . BackendUtility::deleteClause ($table);
        $res = $GLOBALS ['TYPO3_DB']->exec_selectQuery ('*', $table, $where, '', 'categorie');
        if ($res) {
            while ($row = $GLOBALS ['TYPO3_DB']->sql_fetch_assoc ($res)) {
                $label = BackendUtility::getRecordTitle ($table, $row);
                $value = $row ['uid'];
                $config ['items'] [] = Array (
                        $label,
                        $value 
                );
            }
            $GLOBALS ['TYPO3_DB']->sql_free_result ($res);
        }
        return $config;

expected result:
categories are added to "available objects" and only selected items from database are added to "selected items". The itemFormElValue should look like:

[itemFormElValue] => Array
        (
            [0] => 1
            [1] => 3
        )

actual result:
categories are added to "available objects" and selected items from database are added to "selected items" AND the product with ID of number of selected items from database is also added to "selected items". f. example:
you have added to product ID 4 the product with id 1 and 3 to selected objects for "similar produtcs" and saved to database. in mm relation table everything is correct saved. but on opening product with id 4 again the "selected objecs" now also added product with ID 2 (because you have added 2 products for similar products).
the itemFormElValue look now like:

[itemFormElValue] => Array
        (
            [0] => 2
            [1] => 1
            [2] => 3
        )

This bug only occures if you have a table in itemsProcFunc that is used by objec itselfs. If I change table from tx_produktdatenbank_domain_model_categories to f.ex. fe_users this bug is not comming up.

items.jpg View (103 KB) Martin Weymayer, 2019-01-29 09:36


Related issues

Related to TYPO3 Core - Bug #85142: Recent reordering of TCA select items processing makes it impossible to post-process foreign_table items Under Review 2018-06-02

History

#1 Updated by Martin Weymayer 6 months ago

#2 Updated by Susanne Moog 4 months ago

  • Category set to FormEngine aka TCEforms

#3 Updated by Torben Hansen 3 months ago

  • Related to Bug #85142: Recent reordering of TCA select items processing makes it impossible to post-process foreign_table items added

#4 Updated by Patrick Broens 3 months ago

I ran into the same problem with

'renderType' => 'selectMultipleSideBySide'
'foreign_table' => 'my_foreign_table',
'MM' => 'my_mm_table',
'itemsProcFunc' => ClassName::class . '->methodName'

After moving the itemsProcFunc part in
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaSelectItems.php as done in the patch of bug #85142, the extra selected record (which has the id of the amount of selected items) disappeared.

But ... using an itemsProcFunc without the foreign_table does not work anymore. The items are listed, but the selection cannot be saved anymore.

#5 Updated by jochen kast 2 months ago

  • TYPO3 Version changed from 7 to 9
  • PHP Version set to 7.2

i got an error which seems to be part of the problem. i want to use tca select with renderType selectTree without table only with itemsProcFunc. with all other renderTypes of select this is no problem. in case of selectTree there is an an error: TCA Tree configuration is invalid: "foreign_table" not set

Also available in: Atom PDF