Bug #94488
closedpid not configurable in addRecord TCA
0%
Description
TCA/select/selectMultipleSideBySide/addRecord::render() delivers always pid = default=currentPid, so '###SITEROOT###' or 'pid'=>'xx' does not work.
TCA Documentation: https://docs.typo3.org/m/typo3/reference-tca/10.4/en-us/ColumnsConfig/Type/selectMultipleSideBySide.html#fieldcontrol
See typo3/sysext/backend/Classes/Form/FieldControl/AddRecord.php:39
Is:
$options = $this->data['renderData']['fieldControlOptions'];
Should be
$options = $this->data['renderData']['fieldControl']['addRecord'];
Array 'fieldControlOptions' seems never be populated and correct config info is in '['fieldControl'][addRecord]'. Maybe bug is elsewhere (who does fill ['fieldControlOptions']?) but patching this worked for me.
Use Case: this has to work as documented:
...
'someField' => [
'exclude' => true,
'label' => $ll.'.someField',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'size' => 3,
'minitems' => 1,
'fieldControl' => [
'addRecord' => [
'disabled' => false,
'title' => 'addRecordTest for Test',
'setValue' => 'set',
'pid' => '###SITEROOT###', // this does not work as documented!!!
],
'editPopup' => [
'disabled' => false,
],
],
'foreign_table' => 'someTable',
'foreign_table_where' =>
'AND {#someTable}.{#pid} IN(###SITEROOT###) '
],
],
...
If we touch addRecord class anyway, we could enable the marker ###PAGE_TSCONFIG_ID### by something like this:
if (isset($parameterArray['fieldTSConfig']['PAGE_TSCONFIG_ID']))
{
$pid = $parameterArray['fieldTSConfig']['PAGE_TSCONFIG_ID'];
}
Same for Typo3 v9
Updated by Oliver Bartsch over 3 years ago
- Status changed from New to Needs Feedback
Hi, thanks for your report.
Actually the docs are a bit unspecific. Those options are not on first level but in a sub array with the options
array key. Therefore the configuration must look like this:
'someField' => [ 'exclude' => true, 'label' => $ll.'.someField', 'config' => [ 'type' => 'select', 'renderType' => 'selectMultipleSideBySide', 'foreign_table' => 'someTable', 'foreign_table_where' => 'AND {#someTable}.{#pid} IN(###SITEROOT###)', 'size' => 3, 'minitems' => 1, 'fieldControl' => [ 'addRecord' => [ 'disabled' => false, 'options' => [ 'title' => 'addRecordTest for Test', 'setValue' => 'set', 'pid' => '###SITEROOT###' ], ], 'editPopup' => [ 'disabled' => false, ], ], ] ],
Regarding:
If we touch addRecord class anyway, we could enable the marker ###PAGE_TSCONFIG_ID### by something like this:
This is resolved in the AddController
, see: https://github.com/TYPO3/TYPO3.CMS/blob/v10.4.17/typo3/sysext/backend/Classes/Controller/Wizard/AddController.php#L246
Could you please check if both cases work for you?
Thanks in advance.
Updated by Martin no-lastname-given over 3 years ago
Both cases work as expected.
'fieldControl'=> ['options' ...
did the trick. I'll go back to elementary school for reading lessons, or as we said in older days: RTFM
Thanks Pro!
Since it is working for me, we might add the PAGE_TSCONFIG_ID parameter (or the whole PAGE_TSCONFIG_*-magic) here:
https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/CommonProperties/FieldControl/AddRecord.html?highlight=addrecord#confval-options[pid]
Updated by Oliver Bartsch over 3 years ago
- Status changed from Needs Feedback to Closed
Hi, thanks for testing. Since this works for you, I'll close this issue. In case you find another bug, please create a new issue and if related to this one, add a reference.
Regarding the docs, there is already a link to those markers:
pid of the new record. Can be an hard pid setting, or one of these markers, see [[select foreign_table_where]] .
I think this should be fine. Duplicating this content would just increase maintainability overhead.