Adapt.Patrick
Adapt.Patrick
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
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... 🤔
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
Interesting! As you say, it feels a little "hacky" but I'll give it a go, for sure! 🙌
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
As far as I know, I'm doing everything "by the book" per the documentation but I could be missing something crucial.
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
Thank you so much. 🙇‍♂️
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
Correct - that's what I've got... 😬😅
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
Correct & yes, rooms is a relationship on the resource's model. It loads related entries perfectly.
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
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. 🙂
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
No description
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
Section::make('Rooms')
->schema([
RepeatableEntry::make('rooms')
->hiddenLabel()
->schema([
\Filament\Infolists\Components\Actions::make([
\Filament\Infolists\Components\Actions\Action::make('editRoom')
->fillForm()
->form(self::getFormRoom()),
]),
// ...
])
]);
Section::make('Rooms')
->schema([
RepeatableEntry::make('rooms')
->hiddenLabel()
->schema([
\Filament\Infolists\Components\Actions::make([
\Filament\Infolists\Components\Actions\Action::make('editRoom')
->fillForm()
->form(self::getFormRoom()),
]),
// ...
])
]);
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
Sure! 2 secs...
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
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 ([])
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
Thank you! Does this not remove the ability for use to use a custom view(), though?
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
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?
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
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?
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
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. 😓
31 replies
FFilament
Created by damarev on 6/6/2024 in #❓┊help
$getAction() with arguments
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:
public static function infolist(Infolist $infolist): Infolist
{
return $infolist->schema([
Group::make()
->schema([
self::infolistQuoteRooms(),
])
->columnSpan(1),
// ...
]);
}

private static function infolistQuoteRooms(): InfoSection
{
return InfoSection::make('Rooms')
->schema([
RepeatableEntry::make('rooms')
->hiddenLabel()
->schema([
ViewEntry::make('quoteRoom')
->view('filament.infolists.entries.quote-room')
->hiddenLabel()
->registerActions([
self::editRoomAction()
])
])
->contained(false),
])
// ...
}

public static function editRoomAction(): Action
{
// ...

return Action::make('editRoom')
// ...
->fillForm(function (array $arguments) {
$room = new Room($arguments);
})
// ...
public static function infolist(Infolist $infolist): Infolist
{
return $infolist->schema([
Group::make()
->schema([
self::infolistQuoteRooms(),
])
->columnSpan(1),
// ...
]);
}

private static function infolistQuoteRooms(): InfoSection
{
return InfoSection::make('Rooms')
->schema([
RepeatableEntry::make('rooms')
->hiddenLabel()
->schema([
ViewEntry::make('quoteRoom')
->view('filament.infolists.entries.quote-room')
->hiddenLabel()
->registerActions([
self::editRoomAction()
])
])
->contained(false),
])
// ...
}

public static function editRoomAction(): Action
{
// ...

return Action::make('editRoom')
// ...
->fillForm(function (array $arguments) {
$room = new Room($arguments);
})
// ...
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.
31 replies
FFilament
Created by Adapt.Patrick on 6/5/2024 in #❓┊help
Infolist Action `->createAnother()` doesn't exist
While I've got you, @Leandro Ferreira, do you know why section headerActions can't be made to accept some of the default actions (such as CreateAction) and only accept Filament\Infolists\Components\Actions\Action instead?
11 replies
FFilament
Created by Adapt.Patrick on 6/5/2024 in #❓┊help
Infolist Action `->createAnother()` doesn't exist
You legend, @Leandro Ferreira. This worked like a charm! 🙌 Thank you so much for your support. 🔥
11 replies
FFilament
Created by Adapt.Patrick on 6/5/2024 in #❓┊help
Infolist Action `->createAnother()` doesn't exist
Thanks! I'll give this a go.
11 replies
FFilament
Created by Adapt.Patrick on 6/5/2024 in #❓┊help
Infolist Action `->createAnother()` doesn't exist
Not sure I quite understand your question @Leandro Ferreira but I'll try and answer it... I have a ProjectResource which uses the infolist() method to control what is rendered to the /view screen. That infolist is then broken down into multiple infolist Sections which use headerActions(). Example below:
public static function infolist(Infolist $infolist): Infolist
{
return $infolist->schema([
Group::make()
->schema([
self::infolistQuoteGroups(),
// ...
])
->columnSpan(1),
Group::make()
->schema([
// ...
])
->columnSpan(1),
])->columns(2);
}

// ...

private static function infolistQuoteGroups(): InfoSection
{
return InfoSection::make('Quote Groups')
->schema([
// ...
])
->headerActions([
// This is the action that I would like to utilise the createAnother() method on...
Action::make('createQuoteGroup')
->label('Add Quote Group')
->form([
TextInput::make('name')
->required(),
])
->modalFooterActionsAlignment('end')
->modalWidth('xl')
->mutateFormDataUsing(function ($data, $record) {
// ...
})
->action(function ($data) {
// ...
})
]);
}
public static function infolist(Infolist $infolist): Infolist
{
return $infolist->schema([
Group::make()
->schema([
self::infolistQuoteGroups(),
// ...
])
->columnSpan(1),
Group::make()
->schema([
// ...
])
->columnSpan(1),
])->columns(2);
}

// ...

private static function infolistQuoteGroups(): InfoSection
{
return InfoSection::make('Quote Groups')
->schema([
// ...
])
->headerActions([
// This is the action that I would like to utilise the createAnother() method on...
Action::make('createQuoteGroup')
->label('Add Quote Group')
->form([
TextInput::make('name')
->required(),
])
->modalFooterActionsAlignment('end')
->modalWidth('xl')
->mutateFormDataUsing(function ($data, $record) {
// ...
})
->action(function ($data) {
// ...
})
]);
}
11 replies