Skip to content

Commit

Permalink
Allow onValidateContact plugin to show error message (#37540)
Browse files Browse the repository at this point in the history
  • Loading branch information
beefcakefu authored Aug 30, 2023
1 parent f8891fd commit 17585ed
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion components/com_contact/src/Controller/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,23 @@ public function submit()
// Validation succeeded, continue with custom handlers
$results = $this->app->triggerEvent('onValidateContact', [&$contact, &$data]);

$passValidation = true;

foreach ($results as $result) {
if ($result instanceof \Exception) {
return false;
$passValidation = false;
$app->enqueueMessage($result->getMessage(), 'error');
}
}

if (!$passValidation) {
$app->setUserState('com_contact.contact.data', $data);

$this->setRedirect(Route::_('index.php?option=com_contact&view=contact&id=' . $id . '&catid=' . $contact->catid, false));

return false;
}

// Passed Validation: Process the contact plugins to integrate with other applications
$this->app->triggerEvent('onSubmitContact', [&$contact, &$data]);

Expand Down

0 comments on commit 17585ed

Please sign in to comment.