From 9473a8552f89e7d51de0378ce5d59ebb8c3b4bb4 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 17 Dec 2024 11:19:03 +0100 Subject: [PATCH] fix: teach FormBuilder where to look for default values UMap will look into the schema for default values, but untill now FormBuilder wasn't. This fix is not the real fix we want, but let's make this last until then. The real fix is to refactor schema and make obj.properties a Proxy object that will then be consumed by FormBuilder as it is now. --- umap/static/umap/js/umap.forms.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/umap/static/umap/js/umap.forms.js b/umap/static/umap/js/umap.forms.js index 1cc384a3..f19a481a 100644 --- a/umap/static/umap/js/umap.forms.js +++ b/umap/static/umap/js/umap.forms.js @@ -1192,6 +1192,21 @@ U.FormBuilder = L.FormBuilder.extend({ } }, + getter: function (field) { + const path = field.split('.') + let value = this.obj + let sub + for (sub of path) { + try { + value = value[sub] + } catch { + console.log(field) + } + } + if (value === undefined) values = U.SCHEMA[sub]?.default + return value + }, + finish: (event) => { event.helper?.input?.blur() },