formio-sfds
Version:
form.io templates for the SF Design System
69 lines (60 loc) • 2.08 kB
HTML
<html>
<head>
<title>Loading...</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="dist/common.css">
</head>
<body>
<div class="page-node-type-form-page sfgov-translate-lang-es" lang="en">
<div class="form-page">
<div id="formio" class="container p-3" data-resource="https://sfds.form.io/workers-families-first"></div>
</div>
</div>
</div>
<script src="https://unpkg.com/formiojs@4.10.4/dist/formio.full.js"></script>
<script src="dist/formio-sfds.standalone.js"></script>
<script>
(() => {
const root = document.getElementById('formio')
const params = new URLSearchParams(location.search || location.hash.substr(1))
const language = params.get('lang')
const i18n = tryParse(params.get('i18n'))
const renderMode = params.get('mode')
const hooks = tryParse(params.get('hooks'))
const resource = params.get('res') || root.getAttribute('data-resource')
const unlockNavigation = true
const options = {
language,
renderMode,
hooks,
unlockNavigation,
i18n,
googleTranslate: params.get('googleTranslate') === 'true',
prefill: params,
properties: tryParse(params.get('properties')) || {
backURL: "https://sf.gov/apply-building-permit",
backTitle: "Apply for a building permit"
}
}
if (language && params.get('langMode') === 'dom') {
document.documentElement.setAttribute('lang', language)
delete options.language
}
Formio.createForm(root, resource, options).then(form => {
console.log('form ready:', form)
document.title = form.schema.title
})
function tryParse(str) {
if (!str) return
try { return JSON.parse(str) }
catch (error) {
console.error('Unable to parse JSON:', str)
return str
}
}
})()
</script>
</body>
</html>