TYPO3 TCA: Add CSS class selection to inputLink - typo3

I'm trying to add a CSS class selection in a TCA inputLink Field. I was able to create the selection in the RTE Editor and now I want to be able to select the same CSS classes in TCA link input fields.
Here is my current code:
'link' => [
'exclude' => 1,
'label' => 'foo label',
'config' => [
'type' => 'input',
'renderType' => 'inputLink',
'size' => 50,
'max' => 1024,
'eval' => 'trim',
'fieldControl' => [
'linkPopup' => [
'options' => [
'title' => 'foo title',
'class' => [
'valuePicker' => [
'mode' => 'blank',
'items' => [
['button', 'Button Style'],
],
],
],
],
],
],
'softref' => 'typolink',
],
],
I couldn't find anything in the TCA Docs. I thought I would give it a try with the LinkPopup --> options --> class. But (as expected) nothing happens.
How am I able to define such a selection dropdown in the link input field?
I'm using TYPO3 LTS 11.

Not sure if you have configured, what you are describing...
A valuePicker can be placed next to an input field of RenderTypes default, colorpicker, inputLink (-> TCAref). The class field in the linkPopup is a simple (hardcoded) form field without a defined renderType or other TCA configuration (Code insight).
There are only a few options for configuring a linkpopup (-> TCAref):
pid
allowedExtensions
blindLinkFields
blindLinkOptions
Setting a prefilled (not selectable) class seems to be possible via TCAMAIN.linkHandler-options (-> LinkBrowser-API). I found an example in an issue of EXT:bootstrap_package.

Related

TYPO3 Prefill text field in my own extension

I need to save the IP address of a user who fills out my form.
I have tried to do it like this:
'userip' => [
'exclude' => true,
'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myextension_domain_model_myextension.userip',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim',
'default' => '12345'.$_SERVER["REMOTE_ADDR"]
]
],
But that doesn't work. What would be the right way?
$_SERVER["REMOTE_ADDR"] is not available in TCA cause this is BE related stuff.
Use the setter from the model, setUserip($_SERVER["REMOTE_ADDR"]), in your createAction() or initializeCreateAction() to save the value in DB.

Missing TCA labels in inline tt_content relation

We are using the Mask extension for some of our content Elements. (It basically adds dynamic CTypes and additional columns in the tt_content).
Next we have our custom extension whose entities should have a relation to an instance of a Mask module. Which works. The only problem is, that the labels of the inline element aren't showing up.
If we add the same Mask module as normal page content, the labels are showing up just fine.
Domain Model of our ext:
/**
* Returns the intro
*
* #return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\MASK\Mask\Domain\Model\Content> $intro
*/
public function getIntro()
{
return $this->intro;
}
TCA
'intro' => [
'exclude' => 0,
'label' => 'Intro zentriert',
'config' => [
'type' => 'inline',
'foreign_table' => 'tt_content',
'foreign_field' => 'tx_zeppelinregions_content_elements',
'foreign_label' => 'tx_mask_teasergalleryheadline',
'foreign_table_field' => 'tx_zeppelinregions_content_elements_type',
'maxitems' => 1,
'foreign_match_fields' => [
'ctype' => 'mask_introzentriert',
],
'overrideChildTca' => [
'columns' => [
'CType' => [
'config' => [
'default' => 'mask_introzentriert',
'readOnly' => 1,
],
],
],
],
]
],
Missing labels in inline element:
(Note: the default tt_content field labels are showing)
Labels showing when adding an element of the same type as normal page content:

TYPO3 TCA label with UserFunc - how to get HTML formatted label?

I want to format the title showing in a list of TCA items which can contain italic text. But whatever I try, I get only unformatted text - even from RTE text fields.
My base information is "partA", "partB", "partC" and I need a title like "partA : partC - part B"
My Code so far:
<?php
return [
'ctrl' => [
'title' => 'LLL:EXT:myext/Resources/Private/Language/myext.xlf:tx_myext_domain_model_myitem',
'label' => 'partC',
'label_alt' => 'partA',
'formattedLabel_userFunc' => T395\myExt\Classes\UserFuncs\MyBEUserFuncs::class.'->getFullMyitemTitle',
'formattedLabel_userFunc_options' => [
'sys_file' => [
'partC','partA','partB'
]
],
'iconfile' => 'fileadmin/Resource/icons/svgs/myext.svg',
],
'columns' => [
'partC' => [
'label' => 'LLL:EXT:myext/Resources/Private/Language/myext.xlf:tx_myext_domain_model_myitem.partC',
'config' => [
'type' => 'text',
'enableRichtext' => true,
],
],
'partA' => [
'label' => 'LLL:EXT:myext/Resources/Private/Language/myext.xlf:tx_myext_domain_model_myitem.partA',
'config' => [
'type' => 'input',
'size' => '5',
'eval' => 'trim',
],
],
'partB' => [
'label' => 'LLL:EXT:myext/Resources/Private/Language/myext.xlf:tx_myext_domain_model_myitem.partC',
'config' => [
'type' => 'input',
'size' => '5',
'eval' => 'trim',
],
],
],
'types' => [
'0' => ['showitem' => 'partA,partB,partC'],
],
];
And the UF:
<?php
T395\myExt\Classes\UserFuncs;
class MyBEUserFuncs
{
public function getFullMyitemTitle(&$params, &$pObj)
{
echo "Hello World!";
$params['title'] = $params['row']['partA'].' : '.$params['row']['partC'].' - '.$params['row']['partB'];
}
}
Even the echo is not showing. Changing the formattedLabel_userFunc to label_userFunc results in getting a string in right order - but right without any text formats like <i> etc but showing them as text. I'm sure, I'm missing something, but I can't figure out what it is - I was also unable to find any code snippets or examples showing the right way - and the docs from TYPO3 saying only that exists formattedLabel_userFunc and it has options - but no proper example there. Hope you can help me. Thank you!
in the documentation for formattedlabel_userfunc you can find:
[...] return formatted HTML for the label and used only for the labels of inline (IRRE) records.
and for label_userfunc there is the warning:
The title is passed later on through htmlspecialchars() so it may not include any HTML formatting.

Update reference index in fields with rendertype inputLink

Links to files or images in fields which use the renderType inputLink (e.g header_link in the normal content elements) do not update the reference index when the content element is saved.
My TCA:
'config' => [
'type' => 'input',
'renderType' => 'inputLink',
'size' => 50,
'max' => 1024,
'eval' => 'trim',
'fieldControl' => [
'linkPopup' => [
'options' => [
'title' => '',
],
],
],
'softref' => 'typolink'
(the same as in header_link in the content elements)
Is there a possibility to force the correct handling of the reference index? The editors can't see which files are linked and which not, so they can delete the files in file module without error message.
Thanks
this bug was fixed with TYPO3 9.7.12:
https://review.typo3.org/c/Packages/TYPO3.CMS/+/62205

How to add custom wizards in TYPO3 9 TCA?

Related to How to add custom wizards in typo3 7 TCA? how can costum wizards in TYPO3 9 be implemented? I've added my entry to the Routes.php
return [
'tx_csseo_preview' => [
'path' => '/wizard/tx_csseo/preview',
'target' => \Clickstorm\CsSeo\UserFunc\PreviewWizard::class . '::render'
],
'tx_csseo_permalink' => [
'path' => '/wizard/tx_csseo/permalink',
'target' => \Clickstorm\CsSeo\UserFunc\PermalinkWizard::class . '::render'
]
];
How can I add them now to my TCA field?
'tx_csseo_title' => [
'label' => 'LLL:EXT:cs_seo/Resources/Private/Language/locallang_db.xlf:pages.tx_csseo_title',
'exclude' => 1,
'config' => [
'type' => 'input',
'max' => $extConf['maxTitle'],
'eval' => 'trim',
'fieldWizard' => [
'tx_csseo_preview' => [
'disabled' => false,
]
]
]
],
This does not work. What do I miss? Thanks in advance.
Related to your kind of wizard the registration-process is different and extensive explained here. You can leave the entries in Routes.php away (perhaps even the whole file if nothing else is inside).
Registration is done in ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1485351217] = [
'nodeName' => 'importDataControl',
'priority' => 30,
'class' => \T3G\Something\FormEngine\FieldControl\ImportDataControl::class
];
Then reference the new wizard in TCA:
'somefield' => [
'label' => $langFile . ':pages.somefield',
'config' => [
'type' => 'input',
'eval' => 'int, unique',
'fieldControl' => [
'importControl' => [
'renderType' => 'importDataControl'
]
]
]
],
Then finally the class with the "magic"
declare(strict_types=1);
namespace T3G\Something\FormEngine\FieldControl;
use TYPO3\CMS\Backend\Form\AbstractNode;
class ImportDataControl extends AbstractNode
{
public function render()
{
$result = [
'iconIdentifier' => 'import-data',
'title' => $GLOBALS['LANG']->sL('LLL:EXT:something/Resources/Private/Language/locallang_db.xlf:pages.importData'),
'linkAttributes' => [
'class' => 'importData ',
'data-id' => $this->data['databaseRow']['somefield']
],
'requireJsModules' => ['TYPO3/CMS/Something/ImportData'],
];
return $result;
}
}
In the linked example there is still an Ajax Route with corresponding files, including a special defined route, but that's not required to get the basic wizard shown.
Concerning the registration in ext_localconf.php there is above the number 1485351217 as array-key shown. For an own registered node just calculate once the current time as unix-timestamp and enter that instead. So it's unique and can't be mistaken with other definitions of any registered nodes.
In contrast to the linked example I used slightly different descriptions, so I call the process in ext_localconf.php registering, and the inclusion in TCA referencing. Perhaps this small difference makes it a bit more clear.
Icons
Concerning Icons there is still a difference to earlier TYPO3 versions, they have to be registered now too and in TCA they are only referenced too by the registered name. Here in the TCA-file is no icon referenced but the class below makes usage of it. Here is an example how an icon has to be registered in ext_tables.php:
$systemIconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$systemIconRegistry->registerIcon(
'imagemapwizard_link_edit',
\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
[
'source' => 'EXT:imagemap_wizard/Resources/Public/Icons/link_edit.png'
]
);
The new icon registry is implemented starting with TYPO3 version 7.5
Don't forget the configuration in YourExtension/Configuration/Backend/AjaxRoutes.php. See the documentation