$set on modal form hint action

In my resource I have a field with an hintAction, which opens a modal. In the modal, there is a field with a hintAction. This hintAction should set the value of a resource field to the value of the modal field. So this is the hintAction inside the modal:
$key = "teaser";

return Action::make('Übernehmen')
->action(function ($state, $set) use ($key) {
Notification::make()
->title("AI Content \"$key\" übernommen ")
->success()
->send();

return $set($key, $state);
});
$key = "teaser";

return Action::make('Übernehmen')
->action(function ($state, $set) use ($key) {
Notification::make()
->title("AI Content \"$key\" übernommen ")
->success()
->send();

return $set($key, $state);
});
This doesn't work. It shows the notification, but doesn't change the teaser content. I guess its because the $set is for the modal form, not the resource form?
Solution:
Found it. ```php function ($state, $set, $livewire) use ($key) { Notification::make()...
Jump to solution
1 Reply
Solution
bernhard
bernhard3w ago
Found it.
function ($state, $set, $livewire) use ($key) {
Notification::make()
->title("AI Content \"$key\" übernommen ")
->success()
->send();

$livewire->data[$key] = $state;
}
function ($state, $set, $livewire) use ($key) {
Notification::make()
->title("AI Content \"$key\" übernommen ")
->success()
->send();

$livewire->data[$key] = $state;
}

Did you find this page helpful?