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