class EntityReference in Drupal 10
Same name in this branch
- 10 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference
- 10 core/modules/views/src/Plugin/views/style/EntityReference.php \Drupal\views\Plugin\views\style\EntityReference
- 10 core/modules/views/src/Plugin/views/row/EntityReference.php \Drupal\views\Plugin\views\row\EntityReference
- 10 core/modules/field/src/Plugin/migrate/field/d7/EntityReference.php \Drupal\field\Plugin\migrate\field\d7\EntityReference
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/row/EntityReference.php \Drupal\views\Plugin\views\row\EntityReference
- 9 core/modules/views/src/Plugin/views/row/EntityReference.php \Drupal\views\Plugin\views\row\EntityReference
EntityReference row plugin.
Plugin annotation
@ViewsRow(
id = "entity_reference",
title = @Translation("Entity Reference inline fields"),
help = @Translation("Displays the fields with an optional template."),
theme = "views_view_fields",
register_theme = FALSE,
display_types = {"entity_reference"}
)
Hierarchy
- class \Drupal\views\Plugin\views\row\Fields extends \Drupal\views\Plugin\views\row\RowPluginBase
- class \Drupal\views\Plugin\views\row\EntityReference
Expanded class hierarchy of EntityReference
2 string references to 'EntityReference'
- views.view.test_entity_reference.yml in core/
modules/ system/ tests/ modules/ entity_reference_test/ config/ install/ views.view.test_entity_reference.yml - core/modules/system/tests/modules/entity_reference_test/config/install/views.view.test_entity_reference.yml
- views.view.test_entity_reference_entity_test.yml in core/
modules/ system/ tests/ modules/ entity_reference_test/ config/ install/ views.view.test_entity_reference_entity_test.yml - core/modules/system/tests/modules/entity_reference_test/config/install/views.view.test_entity_reference_entity_test.yml
File
- core/
modules/ views/ src/ Plugin/ views/ row/ EntityReference.php, line 21
Namespace
Drupal\views\Plugin\views\rowView source
class EntityReference extends Fields {
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['separator'] = [
'default' => '-',
];
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
// Expand the description of the 'Inline field' checkboxes.
$form['inline']['#description'] .= '<br />' . $this
->t("<strong>Note:</strong> In 'Entity Reference' displays, all fields will be displayed inline unless an explicit selection of inline fields is made here.");
}
/**
* {@inheritdoc}
*/
public function preRender($row) {
// Force all fields to be inline by default.
if (empty($this->options['inline'])) {
$fields = $this->view
->getHandlers('field', $this->displayHandler->display['id']);
$names = array_keys($fields);
$this->options['inline'] = array_combine($names, $names);
}
return parent::preRender($row);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityReference:: |
public | function |
Provide a form for setting options. Overrides Fields:: |
|
EntityReference:: |
protected | function |
Overrides Fields:: |
|
EntityReference:: |
public | function | ||
Fields:: |
protected | property | Does the row plugin support to add fields to its output. | |
Fields:: |
public | function | Perform any necessary changes to the form values prior to storage. |