From b7ecebff94f6da34a72ec26bd6bcb3b36f36a9e7 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 5 Nov 2021 15:10:16 +0100 Subject: [PATCH] Fix form issues when changing question type --- www/form/inner.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/www/form/inner.js b/www/form/inner.js index a8a5a603a..961cee634 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -3698,16 +3698,25 @@ define([ } }); if (res === type || !TYPES[res]) { return; } + var oldOpts = model.defaultOpts || {}; model = TYPES[res]; + Object.keys(oldOpts).forEach(function (v) { + var opts = model.defaultOpts || {}; + if (!opts[v]) { delete (block.opts || {})[v]; } + }); type = res; if (!data) { data = {}; } block.type = res; + framework.localChange(); + var wasEditing = data.editing; + onSave(null, true); var $oldTag = $(data.tag); framework._.cpNfInner.chainpad.onSettle(function () { $(changeType).find('span').text(Messages['form_type_'+type]); data = model.get(block.opts, _answers, null, evOnChange); $oldTag.before(data.tag).remove(); + if (wasEditing) { $(edit).click(); } }); }); });