- ๐ฎ๐นItaly kopeboy Milan
It's a shame this isn't fixed yet after years in core.
Any site builder CANNOT force an entity reference selection: even if his custom logic defined in a View results in 1 item, a checkbox on the entity form will list multiple options, that he cannot even see in the Views' preview!Also, why can't this be fixed in 10.1.x instead of 11?!
- last update
about 1 year ago Patch Failed to Apply I ran into this small issue using webforms to make a more visual selection of nodes. The patches are not working for 10.2.x. Would be great if this could be fixed , because showing ALL the results on a single page will result in performance issues.
- ๐ฎ๐นItaly kopeboy Milan
I was able to fix this just by adding these lines to /core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
(after the
$this->view->setDisplay($display_name);
, before the$entity_reference_options = [
)$this->view->initPager(); $items_per_page = $this->view->getItemsPerPage(); if ($items_per_page > 0) { $limit = $items_per_page; }
- ๐ฎ๐ณIndia anchal_gupta
I have uploaded the patch
Address #53 comment
Please review - Status changed to RTBC
10 months ago 7:10pm 7 February 2024 - ๐ฎ๐นItaly kopeboy Milan
What do you mean?
There is no paging in entity references and if you set a limit in the View with "Display a specified number of items", you are explicitly removing the pager.
I just tested that the pager on another display (of type page) of the same View works. - Status changed to Needs work
10 months ago 5:30am 23 February 2024 The Needs Review Queue Bot โ tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request โ . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
- ๐ฎ๐ณIndia prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan
Prem Suthar โ made their first commit to this issueโs fork.
- Merge request !6750drupal-2772523/2772523-entity-reference-views - Add the code For Enity Referance view working. โ (Open) created by prem suthar
- Status changed to Needs review
10 months ago 6:15am 23 February 2024 - ๐ฎ๐ณIndia prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan
Create the Mr For Issue. Please Review
- Status changed to Needs work
10 months ago 3:42pm 23 February 2024 - ๐บ๐ธUnited States smustgrave
This will need test coverage
#54 appears to have dropped a good portion of the original patch, how come? @Prem Suthar see you opened an MR for that too so maybe you know too?
#54 appears to have dropped a good portion of the original patch
And this removal brought back the problem when the pager is not set, in which case the view returns all the results, instead of the specified limit in the widget.
- Merge request !8449Issue #2772523 by kksandr: fixed limit in entity reference views โ (Open) created by Unnamed author
I believe that in any case we should override the pager with parameters from the EntityReferenceSelection plugin.
And the implementation of what is described in the problem will cause confusion for users who want to determine the limit of results at the widget level.
I opened a new merge request that solves the problem where if a view doesn't have a pager set, all results are displayed.
- Status changed to Needs review
6 months ago 6:53am 19 June 2024 - ๐บ๐ธUnited States smustgrave
smustgrave โ changed the visibility of the branch 2772523-entity-reference-views to hidden.
- ๐บ๐ธUnited States smustgrave
Thanks @kksandr for restoring what was removed in 54 and previous MR
- Status changed to Needs work
6 months ago 10:44pm 19 June 2024 - ๐บ๐ธUnited States smustgrave
1) Drupal\Tests\field\Kernel\EntityReference\Views\ViewsSelectionLimitTest::testLimitedOutput Failed asserting that actual size 20 matches expected size 10. /builds/issue/drupal-2772523/core/modules/field/tests/src/Kernel/EntityReference/Views/ViewsSelectionLimitTest.php:84 FAILURES! Tests: 1, Assertions: 8, Failures: 1.
Shows the test coverage so removing that tag.
Left some small comments on MR
Appears to be close!
- Status changed to Needs review
6 months ago 6:24pm 20 June 2024 - Status changed to RTBC
6 months ago 9:29pm 20 June 2024 - Status changed to Needs work
5 months ago 12:20pm 19 July 2024 - ๐ฌ๐งUnited Kingdom catch
The proposed resolution doesn't match the MR.
Also instead of dynamically changing the pager type, why not validate it when a view is selected?