No selected items shown with selectMultipleSideBySide and MM_match_fields in TYPO3 TCA - typo3

This is my TCA:
tx_csblog_tags' => [
'exclude' => 0,
'label' => 'LLL:EXT:cs_blog/Resources/Private/Language/locallang_db.xlf:tx_csblog_domain_model_post.tags',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_csblog_domain_model_tag',
'foreign_table_where' => ' ORDER BY tx_csblog_domain_model_tag.title ASC',
'MM' => 'tx_csblog_post_tag_mm',
'MM_match_fields' => [
'tablenames' => 'pages',
'fieldname' => 'tx_csblog_tags'
],
'nultiple' => 0,
'size' => 10,
'autoSizeMax' => 30,
'minitems' => 0,
'maxitems' => 9999,
The selected items are stored correct in the database table tx_csblog_post_tag_mm, e.g.
uid_local uid_foreign sorting sorting_foreign tablenames fieldname
143 18 1 0 pages tx_csblog_tags
If I save the record, the selected items will be stored in the database this way, but not shown again as selected. So if I save again, the relations are gone.
Did I miss something or is it not possible to use MM_match_fields like this?

Ok, if I leave the "tablenames" it works.

Related

TYPO3 11LTS: Is bidirectional "allowLanguageSynchronization" possible with a MM relation?

Working on TYPO3 11LTS (latest patch release) we try to achieve a MM relation between products and downloads that can be edited from both sides (bi directional) and have "allowLanguageSynchronization" activated (so the editor just sets the relation in the default language 0) with the following TCA setup:
// Local side (tx_test_domain_model_product)
'downloads' => [
'exclude' => 1,
'label' => 'Related downloads',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_test_domain_model_download',
'foreign_table_where' => 'AND {#tx_test_domain_model_download}.{#pid} = ###PAGE_TSCONFIG_ID### AND tx_test_domain_model_download.sys_language_uid IN (-1,0)',
'MM' => 'tx_test_domain_model_productsdownloads_mm',
'behaviour' => [
'allowLanguageSynchronization' => true,
],
],
'l10n_mode' => 'exclude',
'l10n_display' => 'defaultAsReadonly',
],
// Foreign side (tx_test_domain_model_download)
'products' => [
'exclude' => 1,
'label' => 'Connected products',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_test_domain_model_product',
'foreign_table_where' => 'AND {#tx_test_domain_model_product}.{#pid}=###PAGE_TSCONFIG_ID### AND tx_test_domain_model_product.sys_language_uid IN (-1,0)',
'MM' => 'tx_test_domain_model_productsdownloads_mm',
'MM_opposite_field' => 'downloads',
'behaviour' => [
'allowLanguageSynchronization' => true,
],
],
'l10n_mode' => 'exclude',
'l10n_display' => 'defaultAsReadonly',
],
Depending on which side we are editing the relation in the backend the result is the following in the MM table. (Screenshots show both cases. 1: local side editing, 2: foreign side editing)
So what we see is that the language sync does work for one side but not for both. Depending on which side we update (save) in the backend we can switch the db state between the two states (screenshots) in the MM table.
Are we configuring something wrong here or is this simply not supported?

Problem with TCA columns with foreign table after migrating from LTS 7 to LTS 8

I'm working in a old extension.
After migrating from LTS 7, I have "invalid values (1)" in each of my TCA select types, but the correct value is checked in the list.
All upgrade wizards are OK and Database compare too.
I am using a TCA column with foreign table like this:
$GLOBALS['TCA']['tx_myextension_model'] = array(
'columns' => array(
'diploma_type' => array(
'exclude' => 1,
'config' => array(
'type' => 'select',
'renderType' => 'selectSingle',
'MM' => 'sys_category_record_mm',
'MM_match_fields' => array(
'fieldname' => 'diploma_type',
'tablenames' => 'tx_extension_name',
),
'MM_opposite_field' => 'items',
'foreign_table' => 'sys_category',
'foreign_table_where' => ' AND (sys_category.sys_language_uid = 0 OR sys_category.l10n_parent = 0) AND pid = 35 ORDER BY title',
'size' => 10,
'autoSizeMax' => 20,
'minitems' => 0,
'maxitems' => 20,
'behaviour' => array(
'allowLanguageSynchronization' => true,
)
)
)
)
);
In the table tx_myextension_model.diploma_type TYPO3 save the value 1 and in sys_category_record_mm the correct value.
Any thoughts?

Cascade delete TYPO3 inline records don't work

I have a TYPO3 extension for some products which uses inline records to add documentgroups to a product. Deleting the product should also delete the documentgroups (inline records).
The documentation says behaviour.enableCascadingDelete is set to true by default, but the documentgroups are not deleted. Setting this value in the TCA does not make a difference.
'documentgroups' => [
'exclude' => 1,
'label' => $ll . ".documentgroups",
'config' => [
'type' => 'inline',
'allowed' => 'tx_product_domain_model_docgroup',
'behaviour' => [
'allowLanguageSynchronization' => true,
'enableCascadingDelete' => true,
],
'foreign_table' => 'tx_product_domain_model_docgroup',
'MM' => 'tx_product_mm',
'MM_match_fields' => [
'tablenames' => 'tx_product_domain_model_docgroup',
'fieldname' => 'documentgroups',
'table_local' => $tableName,
],
'foreign_sortby' => 'sorting',
'minitems' => 0,
'maxitems' => 99,
]
],
enableCascadingDelete has no effect on MM related tables. In \TYPO3\CMS\Core\DataHandling\DataHandler->deleteRecord_procBasedOnFieldType the inline type is checked and only if it's of type field (foreign_field must be set in the TCA) or list (MM and foreign_field must not be set in TCA) child entries will be deleted.

TYPO3 singleSelect required

This is my TCA field configuration
'membership_type' => [
'exclude' => 0,
'label' => $ll . '/locallang_db.xlf:my_label.type',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'sys_category',
'foreign_table_where' => ' AND sys_category.parent=' . $membershipTypeParent . ' AND (sys_category.sys_language_uid = 0 OR sys_category.l10n_parent = 0) ORDER BY sys_category.sorting ASC',
'items' => [
[$llg . 'fe_users.groups.unkonwn', 0]
],
],
],
I want this field to be required. I tried setting:
['config']['eval'] = 'required';
['config']['minitems'] = 1;
But none of them seem to do the job. I found also this old thread on typo3 forge which says it is not possible https://forge.typo3.org/issues/60247. I am using TYPO3 8 now.
"Eval does not exist for select fields. However, what you're missing is a field to choose a non-empty value.
I suggest you use a multi-select with two selects (similar to fe_group in pages) where you can only select one item)."
I would prefer to stay with single select instead of multi-select. Is that possible ?
Eval does exist for select fields, there will be something incorrect in your configuration.
Here's an example I made which works
'exampleSelectSingle' => array(
'label' =>'Select Single',
'exclude' => 0,
'config' => array(
'type' => 'select',
'renderType' => 'selectSingle',
'eval' => 'required',
'items' => array(
['Empty',''],
['Label 1','value1'],
['Label 2','value2']
)
),
'size' => 1,
'minitems' => 1
)
This renders correctly with the first (empty) option selected, which triggers the validation:
https://i.stack.imgur.com/EXbdC.png

TYPO3 v4.6 about IRRE (sorting)

We must update the field data sorting sorting.
I set $TCA['tx_table2']['ctrl']['sortby'] = 'sorting';
And i set:
$TCA['tx_table1']['columns']['uid_records'] = array(
............
'config' => array(
'type' => 'inline',
'languageMode' => 'inherit',
'foreign_table' => 'tx_table2',
'foreign_sortby' => 'sorting',
'size' => 1,
'minitems' => 0,
'maxitems' => 100,
)
);
But when moving the recording position, the data field sorting is not updated.
Values are recorded only when creating a new record.
What could be the problem?