Issue #2602326 by Rassoni, Rishabh Vishwakarma, heykarthikwithu, paulocs, borisson_, alexpott: Unused local variable $key (at line 49) in file.field.inc

merge-requests/3666/merge
catch 2023-03-28 11:00:35 +01:00
parent 6b9d678038
commit 80b3daf90d
1 changed files with 5 additions and 6 deletions

View File

@ -20,7 +20,6 @@ use Drupal\Core\Render\Element;
*/ */
function template_preprocess_file_widget_multiple(&$variables) { function template_preprocess_file_widget_multiple(&$variables) {
$element = $variables['element']; $element = $variables['element'];
// Special ID and classes for draggable tables. // Special ID and classes for draggable tables.
$weight_class = $element['#id'] . '-weight'; $weight_class = $element['#id'] . '-weight';
$table_id = $element['#id'] . '-table'; $table_id = $element['#id'] . '-table';
@ -46,7 +45,7 @@ function template_preprocess_file_widget_multiple(&$variables) {
usort($widgets, '_field_multiple_value_form_sort_helper'); usort($widgets, '_field_multiple_value_form_sort_helper');
$rows = []; $rows = [];
foreach ($widgets as $key => &$widget) { foreach ($widgets as &$widget) {
// Save the uploading row for last. // Save the uploading row for last.
if (empty($widget['#files'])) { if (empty($widget['#files'])) {
$widget['#title'] = $element['#file_upload_title']; $widget['#title'] = $element['#file_upload_title'];
@ -57,10 +56,10 @@ function template_preprocess_file_widget_multiple(&$variables) {
// Delay rendering of the buttons, so that they can be rendered later in the // Delay rendering of the buttons, so that they can be rendered later in the
// "operations" column. // "operations" column.
$operations_elements = []; $operations_elements = [];
foreach (Element::children($widget) as $sub_key) { foreach (Element::children($widget) as $key) {
if (isset($widget[$sub_key]['#type']) && $widget[$sub_key]['#type'] == 'submit') { if (isset($widget[$key]['#type']) && $widget[$key]['#type'] == 'submit') {
hide($widget[$sub_key]); hide($widget[$key]);
$operations_elements[] = &$widget[$sub_key]; $operations_elements[] = &$widget[$key];
} }
} }