On changes to the model not explicitly handled by the extension, this method will be called in order to keep model in sync with Dynamic Content
Callback function that executes upon model change.
unsubscribe callback
let currentModel;
sdk.form.onModelChange(model => {
currentModel = model;
});
const unsubscribe = sdk.form.onModelChange((errors, model) => {
setErrors(errors);
setModel(model)
});
unsubscribe()
Allows you to provide a callback to be executed after the readonly state changes. This method can be chained to append multiple callbacks.
Callback function that executes upon readonly state change.
const container = document.querySelector('.container');
const inputs = Array.from(document.querySelectorAll('input'));
sdk.form
.onReadOnlyChange(setReadOnlyClass)
.onReadOnlyChange(disableInputs)
function disableInputs(readOnly) {
inputs.forEach(input => {
input.style.pointerEvents = readOnly ? 'none' : ''
})
}
function setReadOnlyClass(readOnly) {
container.classList[readOnly ? 'add' : 'remove']('read-only')
}
Set the current model state
to set as model
an array containing any JSON Schema errors found.
const sdk = await init();
try {
await sdk.form.setValue({ title: 'hello world' });
} catch (errors) {
if (errors.length) {
console.log(errors);
}
}
Check the validation of your model. Returns an array containing any JSON Schema errors found.
The model you wish to test
If you want to validate a field model and get back an error report ErrorReport
const errors = await sdk.form.validate({ title: 'Hello World' })});
if (errors && errors.length) {
errors.forEach(error => console.log(error));
} else {
// valid
}
Generated using TypeDoc
Get the current model state of all the fields in the form.