3 namespace Drupal\views\Plugin\views\row;
5 use Drupal\Core\Form\FormStateInterface;
8 * EntityReference row plugin.
10 * @ingroup views_row_plugins
13 * id = "entity_reference",
14 * title = @Translation("Entity Reference inline fields"),
15 * help = @Translation("Displays the fields with an optional template."),
16 * theme = "views_view_fields",
17 * register_theme = FALSE,
18 * display_types = {"entity_reference"}
21 class EntityReference extends Fields {
26 protected function defineOptions() {
27 $options = parent::defineOptions();
28 $options['separator'] = ['default' => '-'];
36 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
37 parent::buildOptionsForm($form, $form_state);
39 // Expand the description of the 'Inline field' checkboxes.
40 $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.");
46 public function preRender($row) {
47 // Force all fields to be inline by default.
48 if (empty($this->options['inline'])) {
49 $fields = $this->view->getHandlers('field', $this->displayHandler->display['id']);
50 $names = array_keys($fields);
51 $this->options['inline'] = array_combine($names, $names);
54 return parent::preRender($row);