This is effectively to implement the same feature that went into Drupal core v8.8.x with https://www.drupal.org/project/drupal/issues/3065903 (change record: Options sorting ability has been added to Select form element)
Consider this code:
$options = array(
'something' => t('One thing'),
'something_else' => t('Another thing'),
'yet_another' => t('Yet another thing'),
);
asort($options); // Sort options here, before adding the "nothing" option as the first option.
$form['select_element'] = array(
'#type' => 'select',
'#title' => t('Select something'),
'#options' => array(
'none' => t('Nothing'),
) + $options,
);
This would result in a select element in the form, with its options listed alphabetically, but with the "nothing" option being first (intentionally not included in the sorting): - Nothing - Another thing - One thing - Yet another thing
Now consider the translations of the options in Greek: "Nothing" → "Τίποτα" "Another thing" → "Κάτι άλλο" "One thing" → "Κάτι" "Yet another thing" → "Κάτι ακόμη"
Actual order (not alphabetical, because the sorting has happened in asort()
for the English strings ):
- Τίποτα
- Κάτι άλλο
- Κάτι
- Κάτι ακόμη
Expected order (properly alphabetical, in the translated language - not according to the source language): - Τίποτα - Κάτι - Κάτι ακόμη - Κάτι άλλο
How things should work ideally:
$options = array(
'something' => t('One thing'),
'something_else' => t('Another thing'),
'yet_another' => t('Yet another thing'),
);
$form['select_element'] = array(
'#type' => 'select',
'#title' => t('Select something'),
'#options' => array(
'none' => t('Nothing'),
) + $options,
'#sort_options' => TRUE, // Options are sorted, by their respective translated labels.
'#sort_start' => 1, // Start sorting after the 1st option ("nothing"), which needs to remain at the top of the list.
);
Recent comments
Hello @NumerousHats, I agree with your assessment. I am looking into this situation right now. The root of this problem is that Backdrop CMS is implemented on top of a "stack" of...
Update Core and Theme via Web interface
I just installed a Backdrop CMS site with version 1.27.0. I then used the user interface to download and update Backdrop CMS to 1.30.0. After starting the update process, and on the...
1.30.0 update.php generates incorrect link
I believe my permissions are set up correctly, as I can install modules from the UI. But for whatever reason, I can't update them. I will, however, double check against that documentation.
Update Core and Theme via Web interface