Widget empty if the default value is an integer

Created on 24 July 2025, 7 days ago

Problem/Motivation

An empty widget is rendered when the default value is an integer (one ID) instead of string.

Steps to reproduce

  • Create a media entity and get its ID
  • Add following code to a form (replace the ID)
    $form['media'] = [
      '#type' => 'media_library',
      '#title' => t('Media'),
      '#default_value' => ID_OF_THE_CREATED_MEDIA_AS_AN_INTEGER,
    ];
  • View the form, notice the widget is empty
  • Click the Add media button, notice all checkboxes are disabled
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇧🇪Belgium matthijs

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