question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Unable to save select2_multiple when there are a large number of related objects

See original GitHub issue

Bug report

What I did

I created a select2_multiple on a crud controller for “groups”. You can associate users to groups (in both directions)

What I expected to happen

The page would load and save when there are many users.

What happened

Once the number of users added to a group gets large, the page loads slowly and sometimes fails to save.

What I’ve already tried to fix it

Since this isn’t directly an issue with the code, nothing can fix it directly. The issue is the fact that there are too many users and every time we try to save the page we are trying to save every single user to the group and when the number of users in a group reaches large numbers, such as 3,000 it doesn’t really make sense to save every single user to the group every time you save a group. I don’t know if this is technically a bug because with only a few users it works.

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug… is it still there? Yes

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP 7.4.18 (cli) (built: Apr 27 2021 14:35:46) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.18, Copyright (c), by Zend Technologies
    with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans

### LARAVEL VERSION:
v8.77.1@994dbac5c6da856c77c81a411cff5b7d31519ca8

### BACKPACK VERSION:
4.1.63@c3a09d64090cc15c51df7898889d763aaa335260

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zachweixcommented, Jan 16, 2022

Once I noticed this, I basically added in my crud controller that whenever a group has more than 200 users, to not add that column and instead add a “custom html” with text that says to go to an individual user to add/remove them from the group. I wonder if there should be a flag that you can set some custom number that when an n-n entity or 1-n entity reaches a certain number of elements that this type of text should replace the select field? If that’s so, then this is now a feature request, no longer a “bug” per se

0reactions
tabacitucommented, Feb 5, 2022

Sounds like a reasonable solution. I don’t think a flag would be feasible, because… different people might prefer different solutions at different breakpoints. And while the breakpoint can easily be make customizable… the alternative solution… not so much. No matter how much we try to help in this case, the dev will still be forced to write some code to treat their particular case in their preferred way. So I say… let’s just do “nothing” 😀

Good question though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't set multiple values in Select2 - Stack Overflow
1. Have you tried to set the array directly: $(".select2").select2('val', selectedValues); ? – VisioN. Jul 23, 2014 at 8:37 · Yes now it...
Read more >
In multi-select, selections do not appear in the order ... - GitHub
So, ultimately the issue here is that Select2 is trying to normalize how the results are displayed to match how the data is...
Read more >
Update Tags with Select2 Multiple - How Do I...
User enters some “new” data in the Select2 (an item that isn't in the Select2's current data set), creating a tag. · Your...
Read more >
Options - Select2 - JeeSite
Because Select2 has many options which are camelCase, where words are separated by uppercase letters, you must write these options out with dashes...
Read more >
Fix common Google Ads Editor errors
When using Editor, you may encounter error messages. This article shows you what the most common error messages mean, how to fix them,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found