Bug #87569

itemsProcFunc in TCA in combination with used table not working correct

Added by Martin Weymayer about 2 months ago. Updated 16 days ago.

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

0%

TYPO3 Version:
7
PHP Version:
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

History

#1 Updated by Martin Weymayer about 2 months ago

#2 Updated by Susanne Moog 16 days ago

  • Category set to FormEngine aka TCEforms

Also available in: Atom PDF