Open dankhan-helmet opened 4 weeks ago
Hello there! Thanks for opening your first issue on this repo!
Just a heads-up: Here at Backpack we use GitHub Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.
Backpack communication channels:
backpack-for-laravel
tag;Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
-- Justin Case The Backpack Robot
Bug report
What I did
Created a CRUD::Field on an morphable relation, defining an ajax datasource for the results:
The fetch method is defined as:
What I expected to happen
The results list would show 2 records, and the link to loading more results if there is another results page
What happened
It didn't show the loading more results link, it only showed two results, even though there were more results on another page
What I've already tried to fix it
I noticed that in
select2_from_ajax.blade.php
the code for deciding to paginate looks like this:But in
morphTo_select_ajax.blade.php
the code incorrectly uses:But because
data.current_page
returns1
for the first page, not0
, the pagination decision will always fail if there's only two pages as thelast_page
index will be the same as thecurrent_page
index.Here's the
data
parameter js console output frommorphTo_select_ajax.blade.php@processResult#200
if there's only two pages of data to return:The code to decide whether to paginate obviously fails as it thinks the current page is the last page.
I fixed this by copying to the code from
select2_from_ajax.blade.php
inprocessResults: function (data, params)
at line 208:Is it a bug in the latest version of Backpack?
After I run
composer update backpack/crud
the bug... is it still there?Yup, still there in: "backpack/crud": "^6.7", "backpack/pro": "^2.2",
Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is: