Assigning actions to buttons correctly
I have created a custom view for my page and rather than using the default header actions, I want to use my own buttons and pass the correct method to each button.
Here is my widget class so far:
And here is the markup for my buttons:
When I click on one of the buttons, nothing happens but from what I've read online, this syntax should be correct?
6 Replies
Ngl, this is the 1st time I've seen this. Can you please share a link of where you saw this?
Can you change one of the actions and add
dd('something')
to check if the actions are actually triggered?
eg
Also, can I as why you're using actions if you want to create your own buttons? (especially since you're using filament buttons on your own template)
Either way, your example will never work like this, AFAIK.So the actions do trigger, you can see that in the image attached.
As for the link, it was a mixture of seeing how the actions worked in the
getHeaderActions
method and talking with GPT to see if what I wanted to do was actually possible. I (probably wrongly) assumed that I would be able to pass the actions methods to by buttons to use.
The reason for my own buttons is so the UI is consistent. I will grab an image.
I have 2 widgets, and I want to be able to click buttons within the widget vs having some header actions for the view and some on the widget.

Although, if it will never work, I better get back to the drawing board completely.
Would you happen to know a better way of achieving what I am attempting to?
Try this:
you will probably need to pass the record into the widget and into each action though. I don't think the widget has default access to any records.
so, i think the real issue here is that you are trying to use prebuilt actions that depend on a model / record. if you have a record you should be able to pass it to the action manually.
otherwise you would need to create custom actions instead of using the pre-built ones.
This is all really helpful, thank you. I do have access of the record within a widget as I access some of the other properties. Unless that is not what you mean.