Formio-APIDepFields
by Vedhachala
HTML
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/formiojs@latest/dist/formio.full.min.css">
<script src="https://unpkg.com/formiojs@latest/dist/formio.full.min.js"></script>
</head>
<body>
<div id="formio"></div>
</body>
</html>
JavaScript
let json = {
"components": [{
"label": "Text Field",
"tableView": true,
"customDefaultValue": "fetch('https://run.mocky.io/v3/eba6bcfb-a75b-48ba-9d3d-23ace8b262f9')\n.then(res=>res.json())\n.then(obj => {\n instance.updateValue(obj.foo, {});\n});",
"key": "textField",
"type": "textfield",
"input": true
},
{
"label": "Console Data",
"action": "custom",
"showValidations": false,
"disableOnInvalid": true,
"tableView": false,
"key": "submit",
"type": "button",
"input": true,
"custom": "console.log('data', data);"
}
]
};
window.onload = function() {
Formio.icons = 'fontawesome';
Formio.createForm(document.getElementById('formio'), json)
};