function EntityFormDisplay::getRenderer
Gets the renderer plugin for a field (e.g. widget, formatter).
Parameters
string $field_name: The field name.
Return value
\Drupal\Core\Field\PluginSettingsInterface|null A widget or formatter plugin or NULL if the field does not exist.
Overrides EntityDisplayInterface::getRenderer
3 calls to EntityFormDisplay::getRenderer()
- EntityFormDisplay::buildForm in core/lib/ Drupal/ Core/ Entity/ Entity/ EntityFormDisplay.php 
- Adds field widgets to an entity form.
- EntityFormDisplay::extractFormValues in core/lib/ Drupal/ Core/ Entity/ Entity/ EntityFormDisplay.php 
- Extracts field values from the submitted widget values into the entity.
- EntityFormDisplay::flagWidgetsErrorsFromViolations in core/lib/ Drupal/ Core/ Entity/ Entity/ EntityFormDisplay.php 
- Flags entity validation violations as form errors.
File
- 
              core/lib/ Drupal/ Core/ Entity/ Entity/ EntityFormDisplay.php, line 161 
Class
- EntityFormDisplay
- Configuration entity.
Namespace
Drupal\Core\Entity\EntityCode
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.
