I created a new extension with the extension_builder and added a select-field:
'selectlist' => array(
'exclude' => 1,
'label' => 'LLL:EXT:my_test/Resources/Private/Language/locallang_db.xlf:tx_mytest_domain_model_test.selectlist',
'config' => array(
'type' => 'select',
'renderType' => 'selectSingle',
'items' => array(
array('LLL:EXT:my_test/Resources/Private/Language/locallang.xlf:tx_mytest_domain_model_test.selectlist.item1', 0),
array('LLL:EXT:my_test/Resources/Private/Language/locallang.xlf:tx_mytest_domain_model_test.selectlist.item2', 1),
),
'size' => 1,
'maxitems' => 1,
'eval' => ''
),
),
In the template I access this field with:
<td><f:link.action action="show" arguments="{test : test}"> {test.selectlist}</f:link.action></td>
The problem is that test.selectlist is only the key of the select-item. But what I need is the value (in my case the translated value from locallang.xlf).
I have not found any documentation about how to access the value in the template.
Is it possible? How can I do it?
In my case I can use a work around.
array('LLL:EXT:my_test/Resources/Private/Language/locallang.xlf:tx_mytest_domain_model_test.selectlist.item1', 1),
array('LLL:EXT:my_test/Resources/Private/Language/locallang.xlf:tx_mytest_domain_model_test.selectlist.item2', 2),
and
<f:translate key="tx_joyatest_domain_model_test.selectlist.item{test.selectlist}" />
this works, cause the translation key can be identified by the select-item-key.
Try biesior's answer for "TYPO3 TCA type select in FLUID?". That technique may be helpful to you, or give you an idea.
Related
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
Im writing my own extension. Now i like my textarea to be edited i RTE. I tried some configurations from web and i cannot make it work..
Part of my TCA:
'tasks' => array(
'exclude' => 0,
'label' => 'LLL:EXT:jobs/Resources/Private/Language/locallang_db.xlf:tx_jobs_domain_model_joboffer.tasks',
'config' => array(
'type' => 'text',
'cols' => 40,
'rows' => 15
),
'defaultExtras' => 'richtext[]'
),
Like here: http://docs.typo3.org/typo3cms/CoreApiReference/Rte/InTheBackend/Index.html
NOT WORKING :(
I also tried similar to this: http://typo3blogger.de/der-t3editor-im-tca/ and also cannot make it work. In cms i always see simple textarea. Any ideas how to plug it in?
my TCA script:
'types' => array(
'1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, add_date, reference_number, position, link_url, localization, title, requirements;;;richtext:rte_transform[mode=ts_links], tasks;;;richtext::rte_transform[flag=rte_disabled|mode=ts_css], offer;;;richtext:rte_transform[mode=ts_links], category, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access, starttime, endtime'),
),
and columns:
'tasks' => array(
'exclude' => 0,
'label' => 'LLL:EXT:jobs/Resources/Private/Language/locallang_db.xlf:tx_jobs_domain_model_joboffer.tasks',
'config' => array(
'type' => 'text',
'cols' => 40,
'rows' => 15
),
'defaultExtras' => 'richtext[]'
),
If you field is called tasks, you need in your *showitem** section this code:
tasks;;;richtext::rte_transform[flag=rte_disabled|mode=ts_css],
see e.g. https://github.com/TYPO3-extensions/news/blob/master/Configuration/TCA/tx_news_domain_model_news.php#L612
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.
Is it possible to use FAL in TCA with the type group?
Based on the doc where say…
elementBrowserType (string) (since TYPO3 CMS 6.0) Makes it possible to
set an alternative element browser type ("db" or "file") than would
otherwise be rendered based on the "internal_type" setting. This is
used internally for FAL file fields, where internal_type is "db" but
the element browser should be the file element browser anyway.
…I tried following:
'config' => array(
'type' => 'group',
'internal_type' => 'db',
'MM' => 'sys_file_reference', // with and without this option
'uploadfolder' => '',
'minitems' => 0,
'maxitems' => 99,
'appearance' => array(
'elementBrowserType' => 'file',
'elementBrowserAllowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
),
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
),
…and much more, but it wont work.
Any hints?
You need to use the API: \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('media') (taken from core\Configuration\TCA\pages.php).
http://api.typo3.org/typo3cms/master/html/class_t_y_p_o3_1_1_c_m_s_1_1_core_1_1_utility_1_1_extension_management_utility.html#ab95ff2f805d3ec462e869057339eee04
I have made an extension in Typo3 4.5 with extbase and fluid. Now to insert some data i use the backend module 'list' that makes some forms with the TCA of the tables.
To make a select box optional, I insert an item before the foreign table like this:
'feuser' => array(
'exclude' => 0,
'label' => 'LLL:EXT:yes/Resources/Private/Language/locallang_db.xml:tx_yes_domain_model_schools.feuser',
'config' => array(
'type' => 'select',
'items' => array(
array('', NULL),
),
'foreign_table' => 'fe_users',
'maxitems' => 1,
),
),
Now, since i have a relation (with NULL alowed) in my DB, i have to insert a NULL value. But like this it doesn't work. I have also tried '', "" and 0. But those don't work either.
I would appreciate any help.
Try this:
'items' => array(
array('', -1))
The second parameter in the array is not the value for the db!