Entity Revisions not showing?

Created on 12 March 2024, 10 months ago
Updated 14 March 2024, 10 months ago

Problem/Motivation

I have created a custom entity that is revisionable. If I edit an existing entity and check the box labeled "Create new revision," I expect to see a new revision.

Instead, I see "No revision." If I use drush sql-query "SELECT * from my_entity_revision;" I can see there are revisions being saved.

Steps to reproduce

Use drush generate entity:content to generate a new entity with the name "my_entity" and make sure to answer "Yes" when asked "Make the entity type revisionable? [No]:".

Add the following to the baseFieldDefinitions in my_entity.php

    $fields['first_name'] = BaseFieldDefinition::create('string')
      ->setLabel(t('First Name'))
      ->setRevisionable(TRUE)
      ->setDisplayOptions('form', [
        'type' => 'string_textfield',
        'settings' => [
          'display_label' => TRUE,
        ],
      ])
      ->setDisplayOptions('view', [
        'label' => 'hidden',
        'type' => 'string',
      ])
      ->setDisplayConfigurable('form', TRUE)
      ->setRequired(TRUE);

Save the file, use drush en my_entity to enable the new entity type.

Go to `/my_entity/add` and create a new entity. Save. Edit the entity, changing the first name, and check the box that says "Create new revision." Add some revision message. Save.

Edit the entity again - there are no revisions displayed.

Use drush sql-query "SELECT * from my_entity_revision;" to verify that a revision has been created in the database.

Proposed resolution

N/A

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

πŸ’¬ Support request
Status

Active

Version

10.1 ✨

Component
EntityΒ  β†’

Last updated about 17 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States savanahsteigen@gmail.com

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

Comments & Activities

Production build 0.71.5 2024