Is is possible to start an action listening to an event ?

I've tried this:
$this->dispatch('open-adauga-cerere', [
'ziua' => $ziKey,
'tip' => $ziData['tip'],
]);
$this->dispatch('open-adauga-cerere', [
'ziua' => $ziKey,
'tip' => $ziData['tip'],
]);
and then
#[On('open-adauga-cerere')]
public function fireEvent(): Action
{

return Action::make('adauga_cerere')
->schema(function (Schema $schema) {
return CereriCreate::form($schema);
})
->action(function (array $data) {

// do something
});
}
#[On('open-adauga-cerere')]
public function fireEvent(): Action
{

return Action::make('adauga_cerere')
->schema(function (Schema $schema) {
return CereriCreate::form($schema);
})
->action(function (array $data) {

// do something
});
}
but the action is not triggered, if i put a dd() before return, it does reach there
1 Reply
Dennis Koch
Dennis Koch4d ago
You fire the definition of the action with that code. Not run the actual action. I think you are looking for ->callMountedAction(). Btw. your action definition is wrong. The action name must match the function name.

Did you find this page helpful?