Answer the question
In order to leave comments, you need to log in
How to disable redirect after submitting a web form?
Actually the problem is as follows, there is a form created using the "Web Forms" component. The form works, everything is fine, but there is one caveat.
<form name="SIMPLE_FORM_1" action="/about/" method="POST" enctype="multipart/form-data">
?WEB_FORM_ID=1&RESULT_ID=156&formresult=addok
Answer the question
In order to leave comments, you need to log in
I also wondered when submitting the form with Ajax, as an option:
\Bitrix\Main\EventManager::getInstance()->addEventHandler(
'main',
'OnBeforeLocalRedirect',
'formBeforeRedirect'
);
function formBeforeRedirect($redirectUrl) {
parse_str(parse_url($redirectUrl, PHP_URL_QUERY), $query);
if (!empty($query['WEB_FORM_ID']) && !empty($query['formresult'])) {
die(json_encode([
'error' => 0,
'message' => ''
]));
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question