Allows you to provide a callback to be executed after the form value changes. This method can be chained to append multiple callbacks.
Callback function that executes upon form value change.
const container = document.querySelector('.container');
const submitBtn = document.querySelector('.submitBtn');
sdk.form
.onFormValueChange(setActiveClass)
.onFormValueChange(enableSubmit);
function enableSubmit(formValue) {
const isEmpty = Object.keys(formValue).length === 0;
submitBtn.disabled = isEmpty;
}
function setActiveClass(formValue) {
const hasTitle formValue?.title !== undefined;
container.classList[hasTitle ? 'add' : 'remove']('active');
}
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')
}
Generated using TypeDoc
Get the current model state of all the fields in the form.