Problem/Motivation

When trying to use the entity_view ctools content for a newly created entity (that is not necessarily saved yet) the content plugin throws an exception because it attempts to load the entity from the database, even if it already exists in the context object. This prevents the flexiform module from being able to render previews of an entity in multistep forms.

  $entity_id = $context->argument;
  $entity = entity_load_single($entity_type, $entity_id);

Proposed resolution

Alter the code such that, if $context->data is set, the entity already in $context->data is used instead of attempting to load a fresh copy.

Remaining tasks

  • Write patch

User interface changes

None

API changes

None

CommentFileSizeAuthor
#3 2506781-3.patch706 bytesandrewbelcher
#2 2506781-2.patch821 bytesrlmumford
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rlmumford’s picture

Project: Chaos Tool Suite (ctools) » Entity API
Component: Code » Core integration

Assigning to the right project

rlmumford’s picture

Status: Active » Needs review
FileSize
821 bytes

Here's a patch

andrewbelcher’s picture

FileSize
706 bytes

The previous patch meant that $entity_id wasn't always available. The updated patch ensures it always is.

Chris Matthews’s picture

The 3 year old patch in #3 to entity_view.inc applied cleanly to the latest entity 7.x-1.x-dev and (if still relevant) needs review.