/**
   * Context in which this entity will be used (e.g. 'display', 'form').
   *
   * @var string
   */
  protected $displayContext;

The values are 'view' or 'form'.

Comments

joachim created an issue. See original summary.

pushpinderchauhan’s picture

Assigned: Unassigned » pushpinderchauhan
pushpinderchauhan’s picture

Assigned: pushpinderchauhan » Unassigned
Status: Active » Needs review
StatusFileSize
new493 bytes
joachim’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch! Looks good.

  • xjm committed a61efd8 on 8.3.x
    Issue #2823809 by er.pushpinderrana, joachim: incorrect property docs...

  • xjm committed aa7ec38 on 8.2.x
    Issue #2823809 by er.pushpinderrana, joachim: incorrect property docs...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

I verified that the expected default for view displays is 'view' and not 'display':

core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php:  protected $displayContext = 'form';
core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php:  protected $displayContext = 'view';

I think I know where the confusion came from (in EntityDisplayBase::init()):

$context = $this->displayContext == 'view' ? 'display' : $this->displayContext;
$extra_fields = \Drupal::entityManager()->getExtraFields($this->targetEntityType, $this->bundle);
$extra_fields = isset($extra_fields[$context]) ? $extra_fields[$context] : array();

That sets $extra_fields['display'] if the context is 'view', but $extra_fields['form'] when the context is 'form'.

Committed a61efd8 and pushed to 8.3.x and 8.2.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.