Experiencing odd behaviour with custom Actions
Hi,
I have a small application where the user can design email templates and publish them. Once published, the email templates can be used in other parts of the application.
Therefore I wrote to actions: publish and unpublish Email.
This is the code for the publish action:
The unpublish action is similar, except
MailServiceProvider::publishMailTemplate
.
The table function from the resource:
The Problem is, that it seems that as soon as I publish an email template, the state is preserved.
I published the last email template, and when I click on another entry, the unpublish action is visible and all custom actions refer still to the first published item.
What am I doing wrong?
Thank you!
Edit: I have forgotten the second screenshot:17 Replies
Solution
Second screenshot:
Those templates are using normal auto-incrementing IDs?
Yes, the column is named
id
and is bigint unsigned auto_increment
. Creation, deletion and update works like a charme. the interessting thing is, that this behaviour doesn't apply to the built in CRUD actions of Filament.Hm. Weird. Did you try outputting the id of the record during (appended to the label) to debug this?
Yes, right now after your suggestion. Every record has the same ID of the first published/unpublished record
But only for your actions? Not for the prebuilt ones?
Right
Same behaviour if you move them to the same action group?
Those actions are table actions, right? Not generic actions
Hahaha, no you are right. As soon as i put them in the same action group it works as expected
Yes
Hm. I think I haven seen something like
->key('group-one')
somewhere. Does that method exists and does giving them unique keys work?No, I don't use
->key('group-one')
For me the issue is solved, I don't need to you nested action groups. Should I open a ticket in GitHub?
Thank you again for your assistance (second time this weekend 😉If you have the time to provide a reproduction repo, I'd appreciate it.
Gerne 😉
Is this just a common repo with public access or are ther some specialities to consider?
Just a fresh install of Filament with a simple example that shows the issue
okidoki, will do it
Done.