How do I prefill a plugin's flexform value via TSConfig?
The goal is that when a user creates a new CE with that flexform, that field is already filled in.
This is how the field looks in the flexform.
<settings.fal.storage>
<TCEforms>
<label>LLL:EXT:fileviews/Resources/Private/Language/locallang_flexform.xlf:fileviews.falStorage</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>sys_file_storage</allowed>
<size>1</size>
<default>1</default>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</settings.fal.storage>
I want to predefine it to storage n. We tried this code in Page TSConfig, but no luck yet.
TCEFORM {
tt_content {
pi_flexform {
fileviews_allfilesteaser {
sDEF {
settings\.fal\.storage.default = 1
}
}
}
}
}
Or maybe use TCADefaults?
You missed one level. default is not available directly below [propertyName]. There, only the documented properties are available.
Also below config, there are only limited configuration options available (see TSconfig Reference):
TCEFORM.[tableName].[fieldName].[dataStructureKey].[flexSheet].[flexFieldName].config.[configurationOption] = ...
Related
The FlexForm allows the user to select a page in the backend.
This way I get the page into the template.
With this link I would like to form a link in a template file
The problem:
The following value is passed to me by the user input and FlexForm: How can I build a valid link from it?
impressumSite => 'pages_26'
FlexForm:
<settings.impressumSite>
<label>Some Text/label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</settings.impressumSite>
Template:
<f:link.typolink parameter="{settings.impressumSite}">some text</f:link.typolink>
I also tried f.link.page. Problem here: An explicit UID is required.
Debug result for {settings.impressumSite}
impressumSite => 'pages_26'
Thank you very much for helping
<f:link.typolink parameter="{settings.impressumSite}">some text</f:link.typolink> should do the trick
You could use a viewhelper as a workaround
https://fluidtypo3.org/viewhelpers/vhs/2.1.2/Iterator/ExplodeViewHelper.html
By the way, which TYPO3 version do you use? I just checked flexform settings in a V8 installation. In my case the value only contains the uid (same flexform config as yours)
I added the possibility to set a detailPid in my Extension via flexforms:
<ROOT>
<type>array</type>
<el>
<settings.detailPid>
<TCEforms>
<label>
LLL:EXT:events/Resources/Private/Language/locallang_db.xlf:flexforms.overview.detailPid
</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.detailPid>
</el>
</ROOT>
I want to set the default detailPid via TS in my setup.ts:
plugin.tx_events_eventdetail {
settings {
listPid = {$plugin.tx_events_eventdetail.settings.listPid}
detailPid = {$plugin.tx_events_eventdetail.settings.detailPid}
}
}
My problem is, that if I don't configure a detailPid in my plugin, the default value from my TS is not used. The settings.detailPid in my Controller or in the FLUID-Template is empty. Is there a way to just fix that?
I already looked around and found out, that the news-extension has the same behavior.
Thanks for any help and suggestions!
At least the extensions tt_address and news have a configuration which allow a fallback to TS if flexform is empty. If you need that, you can copy the code and use that in your extension.
There is no configuration available in the core for that.
You can rename your flexforms detailPid path to something like settings.flexform.detailPid then in your controller you may merge the settings from TS with those from the Flexform so that only non empty values will take affect.
ArrayUtility::arrayMergeRecursiveOverrule($this->settings, $this-settings['flexform'])
https://api.typo3.org/typo3cms/current/html/class_t_y_p_o3_1_1_c_m_s_1_1_extbase_1_1_utility_1_1_array_utility.html#af4008bc539411e9114ed53b1b007735b
I have a TYPO3 plugin with a FlexForm. In the FlexForm I added relations to a foreign table. I now need to disable some of the fields of the foreign table. I can't do this via user rights since it's a question of context, not rights.
My FlexForm looks like this:
<settings.moreinfo>
<TCEforms>
<label>my label</label>
<config>
<type>inline</type>
<foreign_table>tx_foo_domain_model_bar</foreign_table>
<foreign_field>content_uid</foreign_field>
<foreign_sortby>sorting</foreign_sortby>
<maxitems>50</maxitems>
</config>
</TCEforms>
</settings.moreinfo>
I thought about TCEFORM, but have no idea how to address the field:
TCEFORM.tt_content.pi_flexform.foobar.general {
settings\.moreinfo {
# maybe here?
}
}
Is there any possibility to disable a field via TSconfig or PHP?
in general you could disable flexform fields. the manual states the possibility:
Other properties also apply to flex form fields, in this case the full property path including the data structure key has to be set:
TCEFORM.[tableName].[fieldName].[dataStructureKey].[flexSheet].[flexFieldName].[propertyName].
The [dataStructKey] represents the key of a FlexForm in
$GLOBALS['TCA'][<tableName>]['columns'][<field>]['config']['ds']. This
key will be split into up to two parts. By default the first part will
be used as identifier of the FlexForm in TSconfig. The second part
will override the identifier if it is not empty, list or *.
For example the identifier of the key my_ext_pi1,list will be my_ext_pi1
and of the key *,my_CType it will be my_CType. See section Pointing to
a data structure of the TCA reference for details.
Some properties apply to whole FlexForm sheets, their property path is
TCEFORM.[tableName].[fieldName].[dataStructureKey].[flexSheet].[propertyName].
it could be problematic if you use . inside of identifiers.
This answer to a different question inspired me to the solution which finally solved my problem!
foreign_types was the solution I was looking for:
<settings.moreinfo>
<TCEforms>
<label>my label</label>
<config>
<type>inline</type>
<foreign_table>tx_foo_domain_model_bar</foreign_table>
<foreign_field>content_uid</foreign_field>
<foreign_sortby>sorting</foreign_sortby>
<maxitems>50</maxitems>
<foreign_types type="array">
<numIndex index="1" type="array">
<showitem>
title, link, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access, hidden;;1, starttime, endtime
</showitem>
</numIndex>
</foreign_types>
</config>
</TCEforms>
</settings.moreinfo>
Let's say I have a FE Plugin with the option to set some sys_category references via the following flexform field:
<settings.categories>
<TCEforms>
<label>Some Label</label>
<config>
<type>select</type>
<foreign_table>sys_category</foreign_table>
<foreign_table_where> AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.sorting ASC</foreign_table_where>
<MM>sys_category_record_mm</MM>
<MM_opposite_field>items</MM_opposite_field>
<MM_match_fields>
<tablenames>tt_content</tablenames>
<fieldname>categories</fieldname>
</MM_match_fields>
<maxitems>9999</maxitems>
<renderMode>tree</renderMode>
<size>10</size>
<treeConfig>
<appearance>
<expandAll>1</expandAll>
<showHeader>1</showHeader>
</appearance>
<parentField>parent</parentField>
</treeConfig>
</config>
</TCEforms>
</settings.categories>
Now I want to get all category Objects referenced in the flexform in the controller of the plugin. What's the best approach to do so? Should’nt there already be a suitable repository function somewhere? Thank you for your help!
There is no dedicated API for that, however normally you wouldn't need the mm-relation. Removing that and having it like
<settings.categories>
<TCEforms>
<label>LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categories</label>
<config>
<type>select</type>
<renderMode>tree</renderMode>
<renderType>selectTree</renderType>
<treeConfig>
<dataProvider>GeorgRinger\News\TreeProvider\DatabaseTreeDataProvider</dataProvider>
<parentField>parent</parentField>
<appearance>
<maxLevels>99</maxLevels>
<expandAll>TRUE</expandAll>
<showHeader>TRUE</showHeader>
<width>600</width>
</appearance>
</treeConfig>
<foreign_table>sys_category</foreign_table>
<foreign_table_where>AND (sys_category.sys_language_uid = 0 OR sys_category.l10n_parent = 0) ORDER BY sys_category.sorting</foreign_table_where>
<size>15</size>
<minitems>0</minitems>
<maxitems>99</maxitems>
</config>
</TCEforms>
</settings.categories>
it is much easier to retrieve the categories. You can also take a look at the CategoryRepository I am using for the news extension https://github.com/georgringer/news/blob/master/Classes/Domain/Repository/CategoryRepository.php
I got an extension which uses itemproc functions to configure the plugins.
/Configuration/FlexForms/Config.xml:
<T3DataStructure>
<meta type="array">
<langChildren>0</langChildren>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>Allgemein</sheetTitle>
</TCEforms>
<type>array</type>
<el>
:
<settings.auswahlKategorie>
<TCEforms>
<label>Anzuzeigende Kategorie wählen:</label>
<config>
<type>select</type>
<itemsProcFunc>Company\myextension\UserFunc\ItemsProcFunc->getCategoryList</itemsProcFunc>
</config>
</TCEforms>
</settings.auswahlKategorie>
:
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
in function definition
/**
* Generiert die Liste der Kategorien.
*
* Wird für den Aufbau der "FlexForm" benötigt.
*
* #param string_array $config TYPO3 config array.
* #return string_array Angepasstes TYPO3 - Config array.
*/
public function getCategoryList($config) {
:
they assume the root page could be accessed with:
$pageId = $config['flexParentDatabaseRow']['pid'];
to access the typoscript configuration:
$conf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Company\\myextension\\Services\\Config');
$conf->setConfFromTsSetup($pageId);
but there is no value $config['flexParentDatabaseRow']['pid'] and so the typoscript from page 0 is fetched, where no typoscript exist.
how can I provide a correct root-page Id (without modifying the sources from the external company)?
I'm pretty sure what they meant is that you have to add the configuration to your flexform config.
Should be something like this:
<config>
<type>select</type>
<itemsProcFunc>Company\myextension\UserFunc\ItemsProcFunc->getCategoryList</itemsProcFunc>
<flexParentDatabaseRow>
<pid>1</pid>
</flexParentDatabaseRow>
</config>
Not sure this is the correct way, but I'm pretty sure that $config refers to that very config section of the flexform or TCA setup if TCA is used.
The problem was the installed compatibility6 extension.
This issue gave the hint:
The breaking change no 70132 ("FormEngine custom functions") in the
TYPO3 core 7.6 suggests using 'flexParentDatabaseRow' instead of 'row'
for retrieving the full parent database row in a userFunc /
itemsProcFunc.
There is no setting I need to do. The values are set when the data is received.