TYPO3 singleSelect required - typo3

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

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.

Add a text filter field to select in TYPO3

Hi guys I am struggling with TYPO3 and I would like to do a search filter on my select.
I have this TCA for my select. I added there also this 'enableMultiSelectFilterTextfield' => true, but nothing changes. Is there a way how to achieve this?
$fields = array(
'my_plugin' => array(
'label' => 'my Fields',
'exclude' => 1,
'config' => array(
'type' => 'select',
'enableMultiSelectFilterTextfield' => true,
'maxitems' => 99999,
'itemsProcFunc' => 'tx_get_list->getList',
'items' => array(
),
),
)
);

DisplayCond equation between two values

I am trying to figure it out how can I display field in TCA when two values of other fields are same?
My configuration is that I have two fields new and old and one field second. I would like to reach that field second is displayed when new and old are same or new=1 (this is working).
$fields[] = array(
'new' => array(
'label' => "New ID",
'exclude' => 1,
'config' => array(
'type' => 'input'
)
),
);
$fields[] = array(
'old' => array(
'label' => "old ID",
'exclude' => 1,
'config' => array(
'type' => 'input'
)
),
);
$fields[] = array(
'second' => array(
'exclude' => 1,
'displayCond' => array(
'OR' => array(
'FIELD:new:=:1',
'FIELD:new:=FIELD:old'
)
),
'config' => array(
'type' => 'input',
'size' => '255',
)
),
);
The syntax ''FIELD:new:=FIELD:old' is not allowed by the display condition parser (which i rewrote in core v8). Thus, you can not compare the values of two different fields directly, and you are not able to solve your issue on a display condition level.
You may solve your issue by adding a new data provider (probably after the EvaluateDisplayConditionDataProvider) that removes your column in your special case, see https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/FormEngine/Index.html for more docs.

TCA file, checkbox default checked

I would like to set a checkbox in the backend to default checked.
In my case it is the field showinpreview in the file /typo3conf/ext/news/Configuration/TCA/tx_news_domain_model_media.php.
I changed the value default to 1, but it has no effect:
'showinpreview' => [
'exclude' => 1,
'label' => $ll . 'tx_news_domain_model_media.showinpreview',
'config' => [
'type' => 'check',
'default' => 1
]
],
When I check the TCA File of tt_content for a checked checkbox it looks like this:
'sectionIndex' => [
'exclude' => 1,
'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:sectionIndex',
'config' => [
'type' => 'check',
'default' => 1,
'items' => [
'1' => [
'0' => 'LLL:EXT:lang/locallang_core.xlf:labels.enabled'
]
]
]
],
The only difference I see is the items. But I do not really understand what this item-value does.
The easiest way to change this value is by overriding TCA with some pageTS. Add following to the pagets of the folder that holds the news records.
TCAdefaults.sys_file_reference.showinpreview = 1
See https://docs.typo3.org/typo3cms/TSconfigReference/PageTsconfig/TCEform/Index.html
For the older EXT:news versions use: TCAdefaults.tx_news_domain_model_media.showinpreview = 1
The value of the field showinpreview is set in news/Configuration/TCA/Overrides/sys_file_reference.php. Apply your change there, and you will be happy.
But be aware: after updating of the news extension your change will be lost.
Just checked - this works for me
'checkbox' => array(
'exclude' => 0,
'label' => 'My Label',
'config' => array(
'type' => 'check',
'default' => '1'
)
),

How to make file_reference in extbase extension in TYPO3 6.1 work?

I have set up a small extension with the extension builder containing a few fields, one of which is the internal_type: 'file_reference'.
'dokument' => array(
'exclude' => 0,
'label' => 'LLL:EXT:publikationen/Resources/Private/Language/locallang_db.xlf:tx_publikationen_domain_model_publikation.dokument',
'config' => array(
'type' => 'group',
'internal_type' => 'file_reference',
//'uploadfolder' => 'uploads/tx_publikationen',
'allowed' => '*',
'disallowed' => 'php',
'size' => 5,
),
),
The field appears in the backend, but the Element browser is unable to show any files to select:
If I remove the "bparams" parameter from the URL shown above, it is able to see the files that are there.
How can this be brought to work?
FAL fields require complicated configuration. To make that easier, there is a function returning the TCA config for such a field.
Its usage for a field that allows only one file looks like this:
'dokument' => array(
'label' => 'LLL:EXT:publikationen/Resources/Private/Language/locallang_db.xlf:tx_publikationen_domain_model_publikation.dokument',
'exclude' => 0,
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'dokument',
array(
'maxitems' => 1,
'minitems' => 1,
'appearance' => array(
'enabledControls' => array(
'dragdrop' => FALSE,
'localize' => FALSE,
),
),
)
),
),
A look into the source code of that function makes me not want to do that manually.