Reputation: 2243
With the folloging TCA configuration I am trying to set the PAGE_TSCONFIG_STR marker for foreign_table_where
TCA field configuration:
'my_field' => [
'exclude' => 1,
'l10n_mode' => 'mergeIfNotBlank',
'label' => 'The label',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'enableMultiSelectFilterTextfield' => true,
'foreign_table' => 'tx_my_foreign_table',
'foreign_table_where' => ' ###PAGE_TSCONFIG_STR### AND tx_my_foreign_table.deleted = 0 AND tx_my_foreign_table.hidden = 0 AND tx_my_foreign_table.sys_language_uid = ###REC_FIELD_sys_language_uid### ORDER BY tx_my_foreign_table.lastname ASC, tx_my_foreign_table.firstname ASC',
'MM' => 'tx_my_table_mm',
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 99,
],
],
As soon as I set the following Page TSConfig, I don't get any foreign records anymore:
TCEFORM.tx_table.my_field.PAGE_TSCONFIG_STR = AND tx_my_foreign_table.pid = 1
This was working perfectly in TYPO3 7, but stoped working in TYPO3 8. Do I need to change anything for TYPO3 8?
EDIT
I did some more debugging and tracked this issue down to the class TYPO3\CMS\Backend\Form\FormDataProvider\AbstractItemProvider
on line 1139. Here you will find the following code:
$pageTsConfigString = $connection->quote($pageTsConfigString);
This results in 'AND tx_my_foreign_table.pid = 1'
(with quotes!) which will generate this foreignTableClause - and this is of course wrong because of the quotes:
'AND tx_mdnewsauthor_domain_model_newsauthor.pid = 1' AND tx_my_foreign_table.deleted = 0 AND tx_my_foreign_table.hidden = 0 AND tx_my_foreign_table.sys_language_uid = 0 ORDER BY tx_my_foreign_table.lastname ASC, tx_my_foreign_table.firstname ASC
Now my new questions: Is this a bug or am I doing something wrong?
Upvotes: 0
Views: 722
Reputation: 33439
Don't put the SQL code in the TsConfig, put it into the TCA.
'foreign_table_where' => ' AND ( ###PAGE_TSCONFIG_STR### = \'FALSE\' OR tx_my_foreign_table.pid = ###PAGE_TSCONFIG_STR### ) AND tx_my_foreign_table.deleted = 0 AND tx_my_foreign_table.hidden = 0 AND tx_my_foreign_table.sys_language_uid = ###REC_FIELD_sys_language_uid### ORDER BY tx_my_foreign_table.lastname ASC, tx_my_foreign_table.firstname ASC',
And
TCEFORM.tx_table.my_field.PAGE_TSCONFIG_STR = FALSE
Upvotes: 2