Warning: Undefined array key "#theme" in Drupal\swiper_formatter\Plugin\views\style\SwiperFormatterStyle->render()

Created on 22 November 2023, 12 months ago
Updated 21 August 2024, 3 months ago

Problem/Motivation

When using a view that has block_content as entity type id, the following warning is generated.
Warning: Undefined array key "#theme" in Drupal\swiper_formatter\Plugin\views\style\SwiperFormatterStyle->render() (line 234 of modules/contrib/swiper_formatter/src/Plugin/views/style/SwiperFormatterStyle.php).

Steps to reproduce

1. Navigate to /admin/structure/block-content, and create a Block Type if you don't have any.
2. Create a few block contents.
3. Create a view that shows "Content Block".
4. Apply the swiper formatter style plugin.
5. If the view is a block, place it somewhere. I used a block in layout builder.
6. Navigate to the page and observe the warning.

Proposed resolution

When debugging this, I noticed that the block content had the key '#entity_type'. So, my proposition is to add an extra case in the if statement that checks for the entity to have it work for this case. I compared with nodes, and indeed nodes don't have it, but block_content has it.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡·πŸ‡΄Romania bbu23

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