Skip to content

Commit 17585ed

Browse files
authored
Allow onValidateContact plugin to show error message (#37540)
1 parent f8891fd commit 17585ed

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

components/com_contact/src/Controller/ContactController.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,23 @@ public function submit()
171171
// Validation succeeded, continue with custom handlers
172172
$results = $this->app->triggerEvent('onValidateContact', [&$contact, &$data]);
173173

174+
$passValidation = true;
175+
174176
foreach ($results as $result) {
175177
if ($result instanceof \Exception) {
176-
return false;
178+
$passValidation = false;
179+
$app->enqueueMessage($result->getMessage(), 'error');
177180
}
178181
}
179182

183+
if (!$passValidation) {
184+
$app->setUserState('com_contact.contact.data', $data);
185+
186+
$this->setRedirect(Route::_('index.php?option=com_contact&view=contact&id=' . $id . '&catid=' . $contact->catid, false));
187+
188+
return false;
189+
}
190+
180191
// Passed Validation: Process the contact plugins to integrate with other applications
181192
$this->app->triggerEvent('onSubmitContact', [&$contact, &$data]);
182193

0 commit comments

Comments
 (0)