FileWidget conditional help description outside condition

Created on 18 July 2025, 15 days ago

Problem/Motivation

This logic for the conditional $element['#description'] should be within the condition, otherwise it could return an error.

if (empty($fid)) {
      $file_upload_help = [
        '#theme' => 'file_upload_help',
        '#description' => $element['#description'],
        '#upload_validators' => $element['#upload_validators'],
        '#cardinality' => 1,
      ];
    }
    $element['#description'] = $this->renderer->renderInIsolation($file_upload_help);

Steps to reproduce

Got an error when setting a default value for image in core 11.2. Earlier core versions doesn't seem to trigger the error but its inherently a bug anyway that we can fix.

Proposed resolution

Move into the condition.

πŸ› Bug report
Status

Active

Version

3.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States apmsooner

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024