Skip to content

Commit

Permalink
Fix issue Form Builder - Redirect option not working Astroid #953
Browse files Browse the repository at this point in the history
  • Loading branch information
sonvnn committed Jan 15, 2025
1 parent 4bfd299 commit c5a5b5a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions framework/elements/formbuilder/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
$return["status"] = 'success';
$return["message"] = $message_success;
$return["code"] = 200;
if ($params->get('enable_redirect', 0) && !empty($params->get('redirect_url', ''))) {
$return["redirect"] = $params->get('redirect_url', '');
}
} else {
throw new \Exception($message_failed);
}
Expand Down
2 changes: 1 addition & 1 deletion framework/elements/formbuilder/formbuilder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<field astroidgroup="message_options" type="astroidtext" label="ASTROID_WIDGET_FORM_SUBMIT_FAILED_LABEL" description="ASTROID_WIDGET_FORM_SUBMIT_FAILED_DESC" name="form_submit_failed" default="Email sent failed, fill required field and try again!"/>

<field astroidgroup="policy_options" name="enable_redirect" type="astroidradio" astroid-switch="true" default="0" label="ASTROID_WIDGET_FORM_ENABLE_REDIRECT_LABEL"/>
<field astroidgroup="policy_options" ngShow="[enable_redirect]==1" label="ASTROID_WIDGET_FORM_REDIRECT_URL_LABEL" description="ASTROID_WIDGET_FORM_REDIRECT_URL_DESC" name="redirect_url"/>
<field astroidgroup="policy_options" ngShow="[enable_redirect]==1" type="astroidtext" label="ASTROID_WIDGET_FORM_REDIRECT_URL_LABEL" description="ASTROID_WIDGET_FORM_REDIRECT_URL_DESC" name="redirect_url"/>
<field astroidgroup="policy_options" name="enable_captcha" type="astroidradio" astroid-switch="true" default="0" label="ASTROID_WIDGET_FORM_ENABLE_CAPTCHA_LABEL"/>

<field astroidgroup="button_options" type="astroidlist" label="ASTROID_WIDGET_GLOBAL_STYLES_LABEL" name="button_style" default="primary">
Expand Down
4 changes: 4 additions & 0 deletions js/formbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class FormBuilder {

if (response.status === 'success') {
statusElement.innerHTML = '<div class="alert alert-success" role="alert">' + response.message + '</div>';
if (typeof response.redirect !== 'undefined') {
window.location.href = response.redirect;
return false;
}
form.reset();
form.querySelectorAll('.google-recaptcha').forEach(function(el) {
grecaptcha.reset(el);
Expand Down
2 changes: 1 addition & 1 deletion js/formbuilder.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c5a5b5a

Please sign in to comment.