Project

General

Profile

Actions

Bug #87569

open

itemsProcFunc in TCA in combination with used table not working correct

Added by Martin Weymayer about 5 years ago. Updated almost 5 years ago.

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

0%

Estimated time:
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.


Files

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

Related issues 2 (1 open1 closed)

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

Actions
Related to TYPO3 Core - Bug #89998: Problem in TCA with type select if MM relation is usedAcceptedGeorg Ringer2019-12-20

Actions
Actions #1

Updated by Martin Weymayer about 5 years ago

Actions #2

Updated by Susanne Moog about 5 years ago

  • Category set to FormEngine aka TCEforms
Actions #3

Updated by Torben Hansen about 5 years ago

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

Updated by Patrick Broens almost 5 years 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.

Actions #5

Updated by jochen kast almost 5 years 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

Actions #6

Updated by Benni Mack over 4 years ago

  • Related to Bug #89998: Problem in TCA with type select if MM relation is used added
Actions

Also available in: Atom PDF