formio-sfds
Version:
The Form.io theme for sf.gov
62 lines (53 loc) • 1.87 kB
HTML
<html lang="en">
<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="/sfgov/forms.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"></div>
</div>
</div>
</div>
<script src="https://unpkg.com/formiojs@{{ pkg.dependencies.formiojs }}/dist/formio.full.min.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 i18nServiceUrl = params.get('i18nServiceUrl')
const resource = params.get('res') || root.getAttribute('data-resource')
window.drupalSettings = { user: { uid: '123' } }
const options = {
language,
i18n,
i18nServiceUrl,
renderMode: params.get('mode'),
hooks: tryParse(params.get('hooks')),
unlockNavigation: params.get('nav') !== 'false',
googleTranslate: params.get('googleTranslate') === 'true',
prefill: params,
properties: tryParse(params.get('properties'))
}
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>