summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/file/file.module
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/file/file.module')
-rw-r--r--core/modules/file/file.module7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 5dd741f0c432..295c35998e44 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -499,7 +499,12 @@ function template_preprocess_file_widget_multiple(&$variables): void {
foreach (Element::children($element) as $key) {
$widgets[] = &$element[$key];
}
- usort($widgets, '_field_multiple_value_form_sort_helper');
+ usort($widgets, function ($a, $b) {
+ // Sorts using ['_weight']['#value'].
+ $a_weight = (is_array($a) && isset($a['_weight']['#value']) ? $a['_weight']['#value'] : 0);
+ $b_weight = (is_array($b) && isset($b['_weight']['#value']) ? $b['_weight']['#value'] : 0);
+ return $a_weight - $b_weight;
+ });
$rows = [];
foreach ($widgets as &$widget) {