提交后重定向(在 Form.io 的托管版本中)
Redirect after submission (in hosted version of Form.io)
我们可以在 Form.io 的云版本中成功提交表单后重定向到另一个 page/form 吗?我正在考虑在用户进行身份验证后重定向到另一种形式,但这也将用于更一般的页面导航。
我看不到任何可以执行此操作的操作,而且我认为(如果我错了请纠正我)我无法访问自托管版本教程中讨论的事件。
谢谢
这可以通过在表单呈现器上附加事件处理程序然后在表单提交后手动重定向来完成。假设您使用 ng2-formio
作为渲染器,您可以按如下方式执行此操作。
<formio src="https://examples.form.io/example" (submit)="(function(submission) {
window.location.href = 'https://form.io';
})($event)"></formio>
只是 posting a link to the answer from the docs with promises 供参考,因为我发现它们很方便。
Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/example')
.then(function(form) {
form.on('submit', (submission) => {
window.location.href = 'https://form.io';
});
form.on('error', (errors) => {
console.log('We have errors!');
})
});
文档由 Travis 根据接受的答案编写,顺便说一句。
我们可以在 Form.io 的云版本中成功提交表单后重定向到另一个 page/form 吗?我正在考虑在用户进行身份验证后重定向到另一种形式,但这也将用于更一般的页面导航。
我看不到任何可以执行此操作的操作,而且我认为(如果我错了请纠正我)我无法访问自托管版本教程中讨论的事件。
谢谢
这可以通过在表单呈现器上附加事件处理程序然后在表单提交后手动重定向来完成。假设您使用 ng2-formio
作为渲染器,您可以按如下方式执行此操作。
<formio src="https://examples.form.io/example" (submit)="(function(submission) {
window.location.href = 'https://form.io';
})($event)"></formio>
只是 posting a link to the answer from the docs with promises 供参考,因为我发现它们很方便。
Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/example')
.then(function(form) {
form.on('submit', (submission) => {
window.location.href = 'https://form.io';
});
form.on('error', (errors) => {
console.log('We have errors!');
})
});
文档由 Travis 根据接受的答案编写,顺便说一句。