fix(sync): do not call getSyncMetadata if it doesn't exist

This can arise when the form isn't bound to a "syncable" object. We
might want to provide an utility to check an object is *syncable*, or a
specific form to not attempt to sync objects which don't need it.
This commit is contained in:
Alexis Métaireau 2024-05-13 13:49:03 +02:00
parent 8e5c434988
commit 898a3e93b2

View file

@ -1186,8 +1186,10 @@ U.FormBuilder = L.FormBuilder.extend({
L.FormBuilder.prototype.setter.call(this, field, value)
this.obj.isDirty = true
if ('render' in this.obj) this.obj.render([field], this)
const { subject, metadata, engine } = this.obj.getSyncMetadata()
if (engine) engine.update(subject, metadata, field, value)
if ('getSyncMetadata' in this.obj) {
const { subject, metadata, engine } = this.obj.getSyncMetadata()
if (engine) engine.update(subject, metadata, field, value)
}
},
finish: function () {