Bug #87569
closeditemsProcFunc in TCA in combination with used table not working correct
0%
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
Updated by Susanne Moog over 5 years ago
- Category set to FormEngine aka TCEforms
Updated by Torben Hansen over 5 years ago
- Related to Bug #85142: Recent reordering of TCA select items processing makes it impossible to post-process foreign_table items added
Updated by Patrick Broens over 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.
Updated by jochen kast over 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
Updated by Benni Mack over 4 years ago
- Related to Bug #89998: Problem in TCA with type select if MM relation is used added
Updated by Georg Ringer 2 months ago
- Status changed from New to Closed
closed as duplicate of #89998