I can create an unsaved ECK entity using entity_create(), then do entity_view() on it to render the fields and such.

But, it throws notices:

Notice: Undefined property: Entity::$id in eck_entity_view_alter() (line 860 of /vagrant/www/ethos7/sites/all/modules/contrib/eck/eck.module).
Notice: Undefined property: Entity::$id in eck__entity__view_callback() (line 517 of /vagrant/www/ethos7/sites/all/modules/contrib/eck/eck.entity.inc).
Notice: Undefined property: Entity::$id in eck__entity__view_callback() (line 522 of /vagrant/www/ethos7/sites/all/modules/contrib/eck/eck.entity.inc).

The notices go away, if you add

$entity->id = NULL;

The entity renders fine with or without it.

Example:

  $entity = entity_create('exhibitor_registration', $product->data['exhibitor_registration']);
  // Following line is needed so we can render an unsaved entity.
  // https://www.drupal.org/node/2421623
  $entity->id = NULL;
  entity_view('exhibitor_registration', array($entity));

Comments

djdevin’s picture

Issue summary: View changes
eric.napier’s picture

Status: Active » Closed (works as designed)

There seems to be precedent in contrib for including entity ID of NULL for this case of creating an unsaved entity: http://www.drupalcontrib.org/api/drupal/contributions!commerce_cardonfil.... I do not believe this is an issue with ECK per say, but more to do with proper interface with Entity API, the module that defines entity_create(). These notices from ECK in this case I believe are valid, I suggest adding the NULL value to your code in order to avoid them.