-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Original data persists when emptying a relationship field with inline_create #3543
Comments
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:
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! -- |
Hello @WayneFrisby thanks for the report. Indeed We are in the process of providing that functionality but it's through a different field, PR is here: #3410 If you want to give it a try, let us know the results. Best, |
I am going to close this due to inactivity. The solution is beeing provided in the mentioned PR. |
Bug report
What I did
I have created many relationship fields. Most work fine.
Tags with Polymorphic relationships work with no casting on its Model.
Yet, on my Business Model I have this relationship and casting to an array
without 'inline_create' set to true with the entity set, it works fine, but once set with like this
I can't make it null once I have any current-value's set.
Everything else works as expected, but once I've added anything to the database, it's impossible (in the UI) to go back to an empty state.
What I expected to happen
Once deleting all items (in this case, phone numbers) then saving, it updates to an empty state.
What happened
The same or similar to #2760
It remains populated with the original value(s).
I can remove many items to 1 fine, but many/one to none, the original data persists.
What I've already tried to fix it
Many things.
I've tried comparing to working relationship fields. Only difference being the relationships and casting to array (due to JSON string) versus no casting (returns Collection).
Dug into the
fetch_or_create
file as this seems like where the issue may be.When clearing the select box the
<select> <option>
's remain, yet disappear from the render block. At first I thought this was a bug (might still be?), yet this seems to happen all the time, even on working fields. So I'm guessing that's just how select2 works? Seems odd, but maybe some sort of accessibility thing? We add options (to the select), but never remove them.The only way I've manged to get it to work (not persist) is to set one
<option>
to an empty value via the dev tools, then save.As for the field definition, I've tried many variations with no luck.
Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is:PHP VERSION:
PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
LARAVEL VERSION:
v8.28.1@73dd43d92fcde6c6abc00658ae33391397ca119d
BACKPACK VERSION:
4.1.x-dev@62856b1f01fc3e05c80140fc22f85ea2aac8368c
The text was updated successfully, but these errors were encountered: