#105015Locale aware sorting of foreign records with selectMultipleSideBySide in the backend
Description
in typo3 v10 and v13, I use a selectMultipleSideBySide to which I set sortItems in the TCA :
'thecolumn' => [
'exclude' => 0,
'label' => 'LLL:EXT:my_ext/Resources/Private/Language/locallang.xlf:sources',
'config' => [
'type' => 'select',
'sortItems' => [
'label' => 'asc',
],
'renderType' => 'selectMultipleSideBySide',
The sort order is managed by the PHP function strcasecmp which only does basic ascii comparision which put accented characters at the end of the list.
This is what I have done locally to fix this ( sorry, not equipped to do a proper pull request )
typo3 10.4.45 /backend/Classes/Form/FormDataProvider/TcaSelectItems.php line 288
typo3 13.2.1 /cms-backend/Classes/Form/Processor/SelectItemProcessor.php line 159
protected function sortItems(array $items, array $sortOrders): array
{
foreach ($sortOrders as $order => $direction) {
switch ($order) {
case 'label':
$direction = strtolower($direction);
* $collator = new \Collator(null);
@usort(
$items,
* function ($item1, $item2) use ($direction, $collator) {
if ($direction === 'desc') {
* return $collator->compare($item1[0], $item2[0]) <= 0;
}
* return $collator->compare($item1[0], $item2[0]);
}
);
break;
This is the first half of the function in typo3 v10, same changes to the other case ‘value’.
It’s almost the same on typo3 v13.
Reviews 2
History 69
-
Garvin Hicking changed category 09/17/24, 20:58
-
Andreas Kienast changed status
NewAccepted 10/07/24, 11:16 -
Gerrit Code Review pushed patch set 1 for main to change 86443 status
AcceptedUnder Review 10/07/24, 11:17 -
Rémi Payette commented 10/07/24, 15:09
-
Gerrit Code Review pushed patch set 2 for main to change 86443 10/07/24, 15:16
-
Gerrit Code Review pushed patch set 1 for 12.4 to change 86552 10/10/24, 18:40
-
Anonymous commented and changed status
Under ReviewResolved done0 %100 % 10/10/24, 19:05Applied in changeset commit:4a0bcf6a3f4e0d5db10a0e519740e760c9c17f5e.
-
Benni Mack changed status
ResolvedClosed 10/15/24, 09:05 -
S P changed Duplicates #95575 10/16/24, 08:15
I think the second case on line 176 :
should also use the \Collator class to do it’s comparisons