Closed (fixed)
Project:
Swiper formatter
Version:
2.1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
20 Feb 2026 at 14:43 UTC
Updated:
6 Mar 2026 at 16:25 UTC
Jump to comment: Most recent
The SwiperFormatter entity's $description property is typed as string, which does not accept null. However, the description field is optional in the admin UI form. This creates an inconsistency:
TypeError: Cannot assign null to property Drupal\swiper_formatter\Entity\SwiperFormatter::$description of type string$entity = \Drupal::entityTypeManager()
->getStorage('swiper_formatter')
->create([
'id' => 'test_swiper',
'label' => 'Test Swiper',
]);
$entity->save();
// TypeError: Cannot assign null to property ... ::$description of type string
Initialize the $description property with an empty string default value on the entity class.
This makes the programmatic behavior consistent with the UI - description remains optional in both contexts, and the property type stays strict without needing to introduce nullability.
$description property default on SwiperFormatterTypeErrorStart within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
bbu23Comment #6
bbu23Will be available in 2.1.0