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

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?

Related

No selected items shown with selectMultipleSideBySide and MM_match_fields in TYPO3 TCA

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.

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

new content element at content wizard

I have some problems with typo 7.6.2
I would like to add my own content elements to the content-element wizard.
My own extension with templates, partials, TypoScript... worked and the element is visible in the content-element wizard.
Content-element Wizard
If I choose the new element and click the place to add the following screen is shown.
(ext_tables.php):
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
$_EXTKEY,
'Configuration/TypoScript',
'Template Extension'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('
mod {
wizards.newContentElement.wizardItems.extra {
header = KCW Inhalte
elements {
mitglied {
icon = ../typo3/sysext/core/Resources/Public/Icons/T3Icons/content/content-header.svg
title = Mitglied
description = Ein Mitglied anlegen
tt_content_defValues {
CType = mitglied
}
}
}
show = *
}
}
');
"Configuration/TCA/Overrides/tt_content.php":
$TCA['mitglied'] = array(
'columns' => array(
'name' => array (
'exclude' => 1,
'label' => 'Vorname Name',
'config' => array (
'type' => 'input',
'size' => '20'
)
),
'spitzname' => array (
'exclude' => 1,
'label' => 'Spitzname',
'config' => array (
'type' => 'input',
'size' => '20'
)
),
'geburtstag' => array (
'exclude' => 1,
'label' => 'Geburtstag',
'config' => array (
'type' => 'input',
'size' => '10',
'eval' => 'date',
)
),
'posten' => array (
'exclude' => 1,
'label' => 'Posten',
'config' => array (
'type' => 'select',
'renderType' => 'selectSingle',
'items' => array (
array('Mitglied'),
array('Präsident'),
array('Kassenwart'),
array('Vergnügungsausschuss'),
),
'size' => 1,
'maxitems' => 1,
)
),
'foto' => array (
'exclude' => 1,
'label' => 'Foto',
'config' => array(
'type' => 'group',
'internal_type' => 'file',
'allowed' => 'jpg',
'max_size' => 1000,
'uploadfolder' => 'uploads/pics/',
'show_thumbs' => 1,
'size' => 3,
'minitems' => 1,
'maxitems' => 1,
'autoSizeMax' => 10,
)
),
),
'types' => array(
'0' => array('showitem' => 'name,spitzname,geburtstag,posten,foto')
)
);
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA']['tt_content'], $tcaTtContent);
I think the problem is located in these lines in ext_tables.php:
tt_content_defValues {
CType = mitglied
}
You have to allow the value mitglied as value of the field cType. The tt_content_devValues just sets the default values for the newly created content element.
TCEFORM.tt_content.cType.addItems.mitglied = Field title
https://docs.typo3.org/typo3cms/TSconfigReference/PageTsconfig/TCEform/Index.html#pagetceformconfobj

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?

Typo3, TCA forms view depending on the chosen option

I have made in backend a TCA form, what will change depending of the value in select field "type":
This select field contains basically the options:
rte text
url
picture
I can make the system working so, that when "rte text" is chosen, it shows specified fields for "rte text", when url is chosen it shows specified fields for "url" etc..
In my case the content is always saved in database in field "content" and the selected type is saved in field "type".
My problem is that I have not found a way to change the "content" form field / configuration, depending on the selected type.
For example when I choose "rte text" it should use for the content field this kind of configuration (rich text editor):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
and when I choose "picture" it should use for the content field this kind of configuration (file uploader):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'group',
'internal_type' => 'file',
'allowed' => '',
'disallowed' => 'php,php3',
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_uploadshere',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
)
),
Is there a way to change that configuration depending of the value in the selectbox. I have tried to put two contents in an array but haven't got it working on that way.
Unfortunately you cannot change the properties of a single field via type.
You can however influence what's being displayed. So you can configure two independent fields and switch the display:
ext_tables.php:
$TCA['tx_yourextension_yourtable'] = array(
'ctrl' => array(
//...
'type'=>'type',
//...
),
);
TCA.php:
$TCA['tx_yourextension_yourtable'] = array(
'ctrl' => $TCA['tx_yourextension_yourtable']['ctrl'],
'types' => array(
0 => array('showitem' => 'content_rte'),
1 => array('showitem' => 'content_image'),
),
'columns' => array(
'content_rte' => array(
'exclude' => 0,
'label' => 'Content',
'config' => array(
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
'content_upload' => array(
'exclude' => 0,
'label' => 'Content',
'config' => array(
'type' => 'group',
'internal_type' => 'file',
'allowed' => '',
'disallowed' => 'php,php3',
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_uploadshere',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
)
),
),
// ...
);
(Note: I've removed system fields like hidden, sys_language_uid etc. for simplicity's sake)