FilamentF
Filament2y ago
Marc

Refresh the form after saving in SPA mode

How can I refresh the form while in SPA mode after saving data?

I make the following modification before storing the value to the database:
->dehydrateStateUsing(function ($state) {
    return str($state)->slug()->toString();
})

But for some reason, after saving, the value remains the same as what the user has entered, you have to reload the page (F5) to show the real value.

A solution for this is:
->lazy()
->afterStateUpdated(function ($state, $set) {
    $set('slug', str($state)->slug()->toString());
})

But this presents another problem, if the user is editing the field and clicks on the save button, the data is not saved.
I suppose it is because he is making the AJAX call to afterStateUpdated and the save button is disabled even though it is not visible visually.

So, how can I recharge the state without having secondary problems?
Was this page helpful?