Getting Ajax when trying to Add Section to Library after 2.x upgrade

Created on 25 March 2025, 15 days ago

Problem/Motivation

Getting ajax error when trying to Add Section to Library after 2.x upgrade.

Steps to reproduce

I have a custom module which implements hook_entity_bundle_field_info_alter() hook to add a computed field.
Below is a code snippet of this hook

function custom_media_entity_bundle_field_info_alter(array &$fields, EntityTypeInterface $entity_type, string $bundle): ?array {
  if ($entity_type->id() == 'media' && $bundle == 'youtube_video') {
    $fields['youtube_video_id'] = BaseFieldDefinition::create('string')
      ->setName('youtube_video_id')
      ->setTargetEntityTypeId('media')
      ->setLabel(t('YouTube Video ID'))
      ->setComputed(TRUE)
      ->setClass(YoutubeVideoId::class);
  }
  return $fields;
}
  1. Now create a block type and add a paragraph reference field to this custom block type
  2. Now enable layout builder on a content type, say page
  3. Now Create a page content and goto the layout tab
  4. add a content block of the type which you have created in step 1 to a section
  5. Now click on Add section to library link in that section
  6. Fill up the required field in the form and click on Add Section button below the form.
  7. On clicking the Add Section button nothing happen and if you goto network tab of browser you will notice an ajax error.
    custom_media_entity_bundle_field_info_alter(): Argument #3 ($bundle) must be of type string, null given, called in /app/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php on line 552 in <em class="placeholder">custom_media_entity_bundle_field_info_alter()</em>

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇳India nitesh624 Ranchi, India

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