Bug #73165
closedStory #69617: FormEngine bugs
TCA Group field filters do not get called for translated items in element browser
100%
Description
While trying to add a filter, that allows only default language items to be selected in a TCEform group field, I discovered that the filter methods do not get called for items, that the element browser renders as the translations of default language items.
To reproduce this error, you have to switch on the "Localization view" in the list module.
Due to this bug, it seems impossible to implement a group field filter, that allows only default language items to be selected.
Updated by Mathias Schreiber over 8 years ago
- Description updated (diff)
- Parent task set to #69617
Updated by Mathias Brodala about 6 years ago
- Subject changed from TCA Group field filters do not get called for translated items to TCA Group field filters do not get called for translated items in element browser
- Status changed from New to In Progress
- Assignee set to Mathias Brodala
- TYPO3 Version changed from 7 to 9
Updated by Gerrit Code Review about 6 years ago
- Status changed from In Progress to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58888
Updated by Gerrit Code Review almost 6 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58888
Updated by Jonas Eberle over 5 years ago
I would like to test this but I am a bit lost as to what I should test and what should happen before/after the patch. Could you maybe help me out?
Updated by Mathias Brodala over 5 years ago
Jonas Eberle wrote:
I would like to test this but I am a bit lost as to what I should test and what should happen before/after the patch. Could you maybe help me out?
You'll need a group
field where you can select a translatable table. Then translate a few records. Now the goal is to only allow selection of the default language in that field. You can implement this using a filter for this field, however you won't be able to filter out the translated records. The patch fixes this.
Updated by Jonas Eberle over 5 years ago
Thank you Mathias, that made me understand it :)
On a side note: is it normal I only get values like that in $parameters['values'] of the filter function?
[ 'tt_content_2' ]
And that the filter does not affect the "suggest" browser (/typo3/index.php?route=/ajax/wizard/suggest/search) at all?
I can happily select all elements there, just that they do not get saved then because my filter function does not allow them.
So that 'filter' actually only makes sense with 'hideSuggest'?
Updated by Mathias Brodala over 5 years ago
Jonas Eberle wrote:
Thank you Mathias, that made me understand it :)
On a side note: is it normal I only get values like that in $parameters['values'] of the filter function?
[...]
You get an array with a values
key which contains record references like this, correct. You can then use e.g. BackendUtility::splitTable_Uid()
and load the records as desired.
And that the filter does not affect the "suggest" browser (/typo3/index.php?route=/ajax/wizard/suggest/search) at all?
I can happily select all elements there, just that they do not get saved then because my filter function does not allow them.So that 'filter' actually only makes sense with 'hideSuggest'?
Well I guess the suggest wizard is another place which needs to be fixed then.
Updated by Gerrit Code Review about 5 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/58888
Updated by Jonas Eberle about 5 years ago
Here's how I tested:
- Create a multilingual site
- Add a filter function https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/Type/Group.html to a 'group' field from EXT:styleguide
I used Configuration/TCA/tx_styleguide_elements_group.php and adapted the first field:
'group_db_1' => [ 'config' => [ 'filter' => [ [ 'userFunc' => 'myFilterFunc', ], ...
- add the filter function somewhere (e.g. to AdditionalConfiguration.php)
function myFilterFunc(array $parameters, $parentObject) { $l = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class)->getLogger(\TYPO3\CMS\Core\Log\LogManager::class /* nvm, we just need a class here with configured logger */ ); $l->critical('myFilterFunc', $parameters); $fieldValues = $parameters['values']; return $fieldValues; }
- add some "Form engine elements - group" elements and translate some
- look in the log or use xdebug to find method calls
- to be continued... don't have time right now
Updated by Jonas Eberle about 5 years ago
7. The filter function gets called when you open the record selector on the field you edited
8. The filter function gets only called for standard language records - making it impossible to filter other languages.
Updated by Gerrit Code Review about 5 years ago
Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61602
Updated by Mathias Brodala about 5 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 8df43ae9485180bb1e9a1bce045f4e65fcc25f52.
Updated by Benni Mack almost 5 years ago
- Status changed from Resolved to Closed