protected function EntityFormField::getPluginInstance in Views Entity Form Field 8
Gets a bundle-specific field widget instance.
Parameters
null|string $bundle: The bundle to load the plugin for.
Return value
null|\Drupal\Core\Field\WidgetInterface The field widget plugin if it is set. Null otherwise.
2 calls to EntityFormField::getPluginInstance()
- EntityFormField::buildOptionsForm in src/
Plugin/ views/ field/ EntityFormField.php - Default options form that provides the label widget that all fields should have.
- EntityFormField::calculateDependencies in src/
Plugin/ views/ field/ EntityFormField.php - Calculates dependencies for the configured plugin.
File
- src/
Plugin/ views/ field/ EntityFormField.php, line 223
Class
- EntityFormField
- Defines a views form element for an entity field widget.
Namespace
Drupal\views_entity_form_field\Plugin\views\fieldCode
protected function getPluginInstance($bundle = NULL) {
// Cache the created instance per bundle.
$bundle = !is_null($bundle) ? $bundle : reset($this->definition['bundles']);
if (!isset($this->fieldWidgets[$bundle]) && ($field_definition = $this
->getBundleFieldDefinition($bundle))) {
// Compile options.
$options = [
'field_definition' => $field_definition,
'form_mode' => 'views_view',
'prepare' => FALSE,
'configuration' => $this->options['plugin'],
];
// Unset type if improperly set and set to prepare with default config.
if (isset($options['configuration']['type']) && empty($options['configuration']['type'])) {
unset($options['configuration']['type']);
$options['prepare'] = TRUE;
}
// Load field widget.
$this->fieldWidgets[$bundle] = $this->fieldWidgetManager
->getInstance($options);
}
return $this->fieldWidgets[$bundle];
}