Disabling action realtime on state change

hey there. I have a custom action in edit resource page given below
Actions\Action::make('someAction')
->action(function () {
})
->disabled(fn(?Model $record) => $record->isDirty())
->outlined()
->hidden(fn(?Model $record) => $record?->trashed()),
Actions\Action::make('someAction')
->action(function () {
})
->disabled(fn(?Model $record) => $record->isDirty())
->outlined()
->hidden(fn(?Model $record) => $record?->trashed()),
What i want, whenever record get dirty I want to disable it. But following code is not reflecting in realtime on state change. what can I do here?
2 Replies
LeandroFerreira
isDirty will work if you change the model attribute, like this:
TextInput::make('your_field')
->live()
->afterStateUpdated(function ($record, $state) {
$record->your_field = $state;
})
TextInput::make('your_field')
->live()
->afterStateUpdated(function ($record, $state) {
$record->your_field = $state;
})
KM Nurunnabi
KM Nurunnabi4w ago
But I am using that Action into header in edit page, not inside form input. So I wanted to know is there anything similar way that can be applied in header action? Okay @Leandro Ferreira now i get your point by that. Thanks it solved.
Want results from more Discord servers?
Add your server