function EntityFormDisplay::getRenderer

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php \Drupal\Core\Entity\Entity\EntityFormDisplay::getRenderer()
  2. 10 core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php \Drupal\Core\Entity\Entity\EntityFormDisplay::getRenderer()
  3. 8.9.x core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php \Drupal\Core\Entity\Entity\EntityFormDisplay::getRenderer()

File

core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php, line 147

Class

EntityFormDisplay
Configuration entity.

Namespace

Drupal\Core\Entity\Entity

Code

public function getRenderer($field_name) {
  if (isset($this->plugins[$field_name])) {
    return $this->plugins[$field_name];
  }
  // Instantiate the widget object from the stored display properties.
  if (($configuration = $this->getComponent($field_name)) && isset($configuration['type']) && $definition = $this->getFieldDefinition($field_name)) {
    $widget = $this->pluginManager
      ->getInstance([
      'field_definition' => $definition,
      'form_mode' => $this->originalMode,
      // No need to prepare, defaults have been merged in setComponent().
'prepare' => FALSE,
      'configuration' => $configuration,
    ]);
  }
  else {
    $widget = NULL;
  }
  // Persist the widget object.
  $this->plugins[$field_name] = $widget;
  return $widget;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.