in TYPO3 v10.4.9 when I use the following tx_csdummy_domain_model_product.php TCA
'items' => [
'l10n_mode' => 'exclude',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_csdummy_domain_model_item',
'foreign_table_where' => ' AND (tx_csdummy_domain_model_item.sys_language_uid IN (0,-1)) ORDER BY title ASC',
'MM' => 'tx_csdummy_product_item_mm',
]
],
],
and in the tx_csdummy_domain_model_item.php TCA
'products' => [
'l10n_mode' => 'exclude',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_csdummy_domain_model_product',
'foreign_table_where' => ' AND (tx_csdummy_domain_model_product.sys_language_uid IN (0,-1)) ORDER BY title ASC',
'MM' => 'tx_csdummy_product_item_mm',
'MM_opposite_field' => 'items',
]
],
],
it works in the default language as it should. But when I have both sites translated, something goes wrong.
For example I have porduct default (uid=1), product translated (uid=2), item default (uid=5) and item translated (uid=6).
A) If I save the product, then the uid of the translated product points to the default language uid of the item.
tx_csdummy_product_item_mm
uid_local uid_foreign
1 5
2 5
B) If I save the item, then the uid of the translated item points to the default language uid of the product.
tx_csdummy_product_item_mm
uid_local uid_foreign
1 5
1 6
With A I can't see the related product in the english version of the item in frontend.
With B I can't see the related item in the english version of the product.
Related
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?
I'm writing a TCA to define a form, and I need to fill the select with the childs categories from sys_category table.
'category' => [
'label' => 'LLL:EXT:hebo_ideas/Resources/Private/Language/locallang_db.xlf:hk_ideas_idea.category',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'sys_category',
'foreign_table_where' => ' AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.sorting ASC',
'MM' => 'sys_category_record_mm',
'size' => 10
],
],
I understand that I have to use foreign_table_where but I don't know what parameter from TYPO3 core database should I use to filter this categories by parent. Or may be my approach is wrong?
If you want to add categories to your table, you should use \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable(). Thats the easiest way. Please have a look at the documentation for details.
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.
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.
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