OrdinaryDev
OrdinaryDev
FFilament
Created by OrdinaryDev on 10/6/2023 in #❓┊help
How to trigger a form save from another action?
Goal: What i am trying to achieve is when a user selects an item, if they hit the suffix 'edit' it will take them to that relationships edit page. Problem: When I click the edit option, it goes to the edit page, but it doesnt save that i selected that thing. Here is my select field
Select::make('video_id')
->relationship('video', 'title')
->searchable()
->allowHtml()
->required()
->getSearchResultsUsing(function (string $search) {
// some irrelevant code
})
->getOptionLabelUsing(function (int $value): string {
// some irrelevant code
})
->suffixAction(
Action::make('edit')
->icon('heroicon-m-pencil-square')
->action(function ($state, ?Model $record) {
// go to video edit page
// somehow trigger form save before navigating away
info("Edit video with id: $state");
})
),
Select::make('video_id')
->relationship('video', 'title')
->searchable()
->allowHtml()
->required()
->getSearchResultsUsing(function (string $search) {
// some irrelevant code
})
->getOptionLabelUsing(function (int $value): string {
// some irrelevant code
})
->suffixAction(
Action::make('edit')
->icon('heroicon-m-pencil-square')
->action(function ($state, ?Model $record) {
// go to video edit page
// somehow trigger form save before navigating away
info("Edit video with id: $state");
})
),
any help would be much appreciated!
5 replies