Closed elythnwaen closed 6 months 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
Hey @elythnwaen thanks for the question.
I am not a fan of using model events in the fields. Some people are, and I think they work "okayish" for simpler scenarios, but then you start hitting this little corner cases and you realize you would just be better by not using the events in the fields.
What does it means actually? So you setup your fields in setupCreateOperation()
for example. When creating an entry, Backpack will setup that operation that contains the fields, so the events will be setup.
When you click Delete
, it's actually the setupDeleteOperation()
that is run, where you don't have your fields setup, so no model events are registered.
You have a few options here:
setupDeleteOperation()
too. setup()
method (I would advise you to do this if want to keep defining the events on the controller) https://backpackforlaravel.com/docs/6.x/crud-operation-create#use-events-in-your-setup-methodAnd... that's it.
Hope it helps, I am going to close this as I don't think there is any issue here, I've just added a note about this scenario to our docs https://github.com/Laravel-Backpack/docs/pull/548
Cheers 🙏
Setting the events on the setup() method fixed it, thanks!
In case someone check it in the future:
Anyway issue solved for me.
Bug report
What I did
Set up deleted/deleting events using the fluent syntax on my fields. Then pushed the delete button to remove an entry and test it.
What I expected to happen
Execute the code in the event.
What happened
Nothing
What I've already tried to fix it
I tested other events (creating, created, saving, saved, updating, updated), they work fine.
Is it a bug in the latest version of Backpack?
Not sure, I didn’t try it in previous versions, but from what I found while searching for it, it seems like it did work at some point at least.
After I run
composer update backpack/crud
the bug... is it still there? YesBackpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is:PHP VERSION:
PHP 8.2.10 (cli) (built: Aug 29 2023 21:51:44) (ZTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.2.10, Copyright (c) Zend Technologies
LARAVEL VERSION:
10.29.0.0
BACKPACK PACKAGE VERSIONS:
backpack/backupmanager: v5.0.0 backpack/basset: 1.2.1 backpack/crud: 6.6.1 backpack/generators: v4.0.2 backpack/permissionmanager: 7.1.0 backpack/pro: 2.0.18 backpack/theme-coreuiv4: 1.1.1