F
Filament2mo ago
w5m

Refresh form Select component via Section headerAction (inside Resource file)

I've been attempting and failing to refresh a Select component after calling an approve() method on a Review model, which sets a model attribute called review_status_id to ReviewStatus::Approved (an enum case) and saves the record. This is all within the ReviewResource file. If I refresh the browser, I see the updated status, but I'd like the Select component automatically display the new status as the selected option. I'm sure this is easy to achieve, but unfortunately my knowledge of Livewire is somewhat limited at the moment.
class ReviewResource extends Resource
{
protected static ?string $model = Review::class;

public static function form(Form $form): Form
{
return $form
->schema([
Section::make('Review Details')
->headerActions([
Action::make('approve')
->requiresConfirmation()
->action(function (Review $record): void {
$record->approve();
$record->refresh(); // this line has no effect
}),
])
->schema([
Select::make('review_status_id')
->label('Review status')
->options(ReviewStatus::class)
->live()
])
]);
}
}
class ReviewResource extends Resource
{
protected static ?string $model = Review::class;

public static function form(Form $form): Form
{
return $form
->schema([
Section::make('Review Details')
->headerActions([
Action::make('approve')
->requiresConfirmation()
->action(function (Review $record): void {
$record->approve();
$record->refresh(); // this line has no effect
}),
])
->schema([
Select::make('review_status_id')
->label('Review status')
->options(ReviewStatus::class)
->live()
])
]);
}
}
Any pointers would be gratefully received.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server