$livewire->dispatch('refresh') not updating data

Hi all! I have a form where some of the form is in it's own section, where I've used the footerActions on the form to allow the user to save some of the form data. But when saving the data in that action, the form doesn't rerender or reload or show any updates. I could find some posts in here mentioning using the $livewire->dispatch('refresh') which sort of works, but it doesn't update the latest changes, only the second latest if that makes sense? an example:
Section::make()->schema([
App\Models\Test::all()->map(fn ($test) => return TextInput::make('test_'.$test->id)->disabled(fn() => $test->closed_at));
])->footerActions([
Action::make('save')
->label('Save')
->action(function($get, $livewire) {
$tests = App\Models\Test::all();
foreach($tests as $test) {
$value = $get('test_' . $test->id);
$test->update(['value' => $value, 'closed_at' => now()]);
$livewire->dispatch('refresh')
}
})
]);
Section::make()->schema([
App\Models\Test::all()->map(fn ($test) => return TextInput::make('test_'.$test->id)->disabled(fn() => $test->closed_at));
])->footerActions([
Action::make('save')
->label('Save')
->action(function($get, $livewire) {
$tests = App\Models\Test::all();
foreach($tests as $test) {
$value = $get('test_' . $test->id);
$test->update(['value' => $value, 'closed_at' => now()]);
$livewire->dispatch('refresh')
}
})
]);
When i input the value in the first field and press save, it saves the information but it doesn't update the "disabled" to true, but when i just continue also inputting data in the next field and pressing save, the first field os now disabled but not the one I've just updated
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?