Documentation - Specific Template Overrides
by brendanbond
HTML
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
/>
<link rel="stylesheet" href="https://cdn.form.io/js/formio.full.min.css" />
<script src="https://cdn.form.io/js/formio.full.js"></script>
<div class="container">
<div id="formio"></div>
</div>
JavaScript
/*
* The @formio/js rendering engine applies templates in this order:
* `${templateName}-${component.type}-${component.key}`,
* `${templateName}-${component.type}`,
* `${templateName}-${component.key}`,
* `${templateName}`
* Uncomment some of the examples below to try out different levels of granularity
*/
Formio.Templates.current = {
// override all input component templates (this would include components like Number and Email)
// input: {
// form: (ctx) => `<div>Template overridden!</div>`
// },
// override all text field component templates
// 'input-textfield': {
// form: (ctx) => `<div>Template overridden!</div>`
// }
// override just the firstName component
'input-textfield-firstName': {
form: (ctx) => `<div>Template overridden!</div>`
}
}
Formio.createForm(document.getElementById("formio"), "https://examples.form.io/simpleform");