From e28f264ef61ca846c22353dfeb98d86a7f76ca0b Mon Sep 17 00:00:00 2001 From: xO-Tx Date: Fri, 25 Jun 2021 12:56:16 +0000 Subject: [PATCH] [IMP] website_form: keep label when input changes Changing the input type should not change the label name. The goal of this commit is to keep old label when input type changes and set the default label names for new fields only. Part of https://github.com/odoo/odoo/pull/68061 task-2431484 --- .../static/src/snippets/s_website_form/options.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website_form/static/src/snippets/s_website_form/options.js b/addons/website_form/static/src/snippets/s_website_form/options.js index b6df25dc588..e04cd492181 100644 --- a/addons/website_form/static/src/snippets/s_website_form/options.js +++ b/addons/website_form/static/src/snippets/s_website_form/options.js @@ -821,8 +821,8 @@ options.registry.WebsiteFieldEditor = FieldEditor.extend({ if (!value) { return; } - const name = this.el.querySelector(`[data-custom-field="${value}"]`).textContent; - const field = this._getCustomField(value, `Custom ${name}`); + const oldLabelText = this.$target[0].querySelector('.s_website_form_label_content').textContent; + const field = this._getCustomField(value, oldLabelText); this._setActiveProperties(field); await this._replaceField(field); this.rerender = true;