diff --git a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php index 84dbbd7..c149387 100644 --- a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php +++ b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php @@ -196,7 +196,10 @@ protected function initializeView($match = NULL, $match_operator = 'CONTAINS', $ } $this->view->setDisplay($display_name); $this->view->initPager(); - $limit = $this->view->getItemsPerPage(); + $items_per_page = $this->view->getItemsPerPage(); + if (!empty($items_per_page)) { + $limit = $items_per_page; + } // Pass options to the display handler to make them available later. $entity_reference_options = [ diff --git a/core/modules/views/src/Plugin/views/display/EntityReference.php b/core/modules/views/src/Plugin/views/display/EntityReference.php index 4dedd51..30eb620 100644 --- a/core/modules/views/src/Plugin/views/display/EntityReference.php +++ b/core/modules/views/src/Plugin/views/display/EntityReference.php @@ -156,6 +156,14 @@ public function query() { $this->view->query->addWhere(0, $id_table . '.' . $id_field, $options['ids'], 'IN'); } + // If the display has no pager set (plugin ID equals 'none'), set one. + if ($this->view->getPager()->getPluginId() === 'none') { + /** @var \Drupal\views\Plugin\ViewsPluginManager $pager_plugin_manager */ + $pager_plugin_manager = \Drupal::service('plugin.manager.views.pager'); + /** @var \Drupal\views\Plugin\views\pager\PagerPluginBase $pager */ + $this->view->pager = $pager_plugin_manager->createInstance('some'); + $this->view->pager->init($this->view, $this->view->getDisplay()); + } $this->view->setItemsPerPage($options['limit']); }