Skip to content

Commit

Permalink
Create message with context values
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk committed Dec 13, 2024
1 parent 29b4477 commit c230a1f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/AbstractForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ protected function createComponentForm(): Form
$form->onSuccess[] = function(Form $form, ArrayHash $data): void { // @phpstan-ignore assign.propertyType
$this->catch($this->handleSuccess(...), $form, $data);
};

$form->onSuccess[] = function(Form $form, ArrayHash $data): void { // @phpstan-ignore assign.propertyType
$this->trigger('success', $form, $data, $this);
$this->redrawControl();
Expand Down Expand Up @@ -418,7 +419,10 @@ private function catch(callable $method, Form $form, ArrayHash $data): void
}

/** @var BaseControl $control */
$control->addError('web.message.entity-not-found');
$control->addError(new Message('web.message.entity-not-found', [
'field' => $e->getEntityName(),
'id' => $e->getId(),
]));

} catch (ForbiddenRequestException) {
$form->addError('web.message.permission-denied');
Expand Down

0 comments on commit c230a1f

Please sign in to comment.