$getAction() with arguments
Is it possible to render a Infolists\Components\Actions\Action registered on a Infolists\Components\Entry via $this->registerActions(), passing arguments from the view?
I have:
I have tried with no result:
24 Replies
it should be this
https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component#passing-action-arguments
Are you able to render the action?
Thank you Leandro. Yes I have tried this also:
and in the view
But it throws an exception: Livewire\Exceptions\PropertyNotFoundException - Property not found on component.
I'm experiencing something similar here, @damarev & @LeandroFerreira. Any chance you've made any progress? My setup looks like this from the
infolist()
method of a resource:
I'm then calling the editRoomAction()
in my filament.infolists.entries.quote-room
template with {{ $getAction('editRoom') }}
My issue is $arguments
in the editRoomAction()
method is empty.
The call to my editRoom
action from the view successfully renders a button which opens a modal, but the contents of the form is empty as the $arguments
parameter of the fillForm()
callback is an empty array. 😓Why not an action in the repeater?
Thanks for getting back to me @Leandro Ferreira. Will that still allow us to use a custom view file for the rendering of each item in the repeater?
maybe you could try this way to achieve what you need
Forgive me, but I'm not sure I'm following where this
Actions::make()
call is supposed to live? Is it part of the RepeatableEntry::make()
call?Thank you! Does this not remove the ability for use to use a custom
view()
, though?no, you can combine
That doesn't appear to be receiving any data to the form either, I'm afraid. The
$arguments
parameter is still coming through as an empty array ([]
)could you share the code?
Sure! 2 secs...
This produces this in the UI. Clicking the Edit Room button opens a modal, but it's empty.
hum.. you want to pass the repeater data to the form.. 🤔
I should say,
self::getFormRoom()
is just a wrapper to return the array of form fields (just to help keep the code tidy). So it should use the same context as if I were to declare them directly in the ->form()
call. 🙂yes, and you want to fill the edit form with the repeater data, right?
Is
rooms
a relationship?Correct & yes,
rooms
is a relationship on the resource's model. It loads related entries perfectly.you want to create a
Repeater
in a Infolist 😅Correct - that's what I've got... 😬😅
now I know why you are registering an action..
let me think about it..
Thank you so much. 🙇♂️
As far as I know, I'm doing everything "by the book" per the documentation but I could be missing something crucial.
maybe we have a better way, but I think you could try this:
Add this action to your ViewPage
Create a
custom-repeater-entry.blade.php
in your resources/view folder and copy the default content from repeater-entry.blade.php.
Add the action:
Use this view in the Repeater:
Interesting! As you say, it feels a little "hacky" but I'll give it a go, for sure! 🙌
Hmm, I think we might be getting somewhere with this now. I'd be keen to keep this thread open though, as you've already said, I feel there should be a more elegant solution to this... 🤔