Hi cipa, thank you for pointing me in that direction, I was already looking into hooks and preHooks, and was pretty certain that was the way to go, the problem is that I just don’t have the faintest idea as to how I can access, or how I can tell if the form has not been sent.
There’s no built-in hook to redirect upon unsuccessful sending, so I thought I’d take a look at formit.php (formit snippet) and I think I was pretty close to hardcoding the redirect by adding this:
$url = $modx->makeUrl(123);
$modx->sendRedirect($url);
under the line 180 in this else statement:
else {
$modx->toPlaceholders($fi->validator->errors,$placeholderPrefix.'error');
$errs = array();
foreach ($fi->validator->errorsRaw as $field => $err) {
$err = $field.': '.$err;
$errs[] = str_replace('[[+error]]',$err,$validationErrorBulkTpl);
}
$errs = implode($validationErrorBulkSeparator,$errs);
$validationErrorMessage = str_replace('[[+errors]]',$errs,$validationErrorMessage);
$modx->setPlaceholder($placeholderPrefix.'validation_error',true);
$modx->setPlaceholder($placeholderPrefix.'validation_error_message',$validationErrorMessage);
/* ---- > right here */
}
But no cookie, so I kept going back to the drawing board a few times til I gave up and decided to just add a line before the send button where I state that if you don’t get a thank you page, the form hasn’t been sent.
If anybody ever figures out how to make a preHook to redirect when the form fails, please share your findings.
Thanks again.