Formio.createForm(document.getElementById('formio'), 'https://formsengine.zaaz.cloud/imm5645familyvisitorsstudentsandworkers',
{
language: 'en',
})
.then(function(form) {
var languages = {en: true};
window.setLanguage = function(lang) {
// If we already have loaded the language, then just set it with the sdk.
if (languages[lang]) {
return form.language = lang;
}
// Fetch the language from the Resource.
Formio.fetch('https://formsengine.zaaz.cloud/language/submission?data.language=' + lang).then(function(resp) {
return resp.json();
}).then(function(result) {
// Ensure future sets will use the cached language.
languages[lang] = true;
// Add this language.
form.addLanguage(lang, result[0].data.translation);
// Set this language.
form.language = lang;
});
};
// What to do when the submit begins.
form.on('submitDone', function(submission) {
console.log('done');
window.location = 'thanks';
});
});