entity_id field break the jsonapi integration, since entity_reference field type config is incomplete

Created on 27 November 2024, 5 months ago

entity_reference field type need a fixed entity type to be configured, this code miss it:

src/Entity/Like.php

    $fields['entity_id'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Entity ID'))
      ->setDescription(t('The ID of the entity of the like.'))
      ->setRequired(TRUE);

Since entity_id field here need to accept entity id of any entity type, it should not use the entity_reference field type.
Simply change the field type to integer can resolve this proplem.

    $fields['entity_id'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Entity ID'))
      ->setDescription(t('The ID of the entity of the like.'))
      ->setRequired(TRUE);
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇨🇳China 司南

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

Comments & Activities

Production build 0.71.5 2024