diff --git a/addons/website/static/src/snippets/s_website_form/options.js b/addons/website/static/src/snippets/s_website_form/options.js index 72d00c05e18..efc8ecaa9d4 100644 --- a/addons/website/static/src/snippets/s_website_form/options.js +++ b/addons/website/static/src/snippets/s_website_form/options.js @@ -1316,6 +1316,8 @@ options.registry.WebsiteFieldEditor = FieldEditor.extend({ * @param {HTMLElement} fieldEl */ _replaceFieldElement(fieldEl) { + const inputEl = this.$target[0].querySelector('input'); + const dataFillWith = inputEl ? inputEl.dataset.fillWith : undefined; const hasConditionalVisibility = this.$target[0].classList.contains('s_website_form_field_hidden_if'); const previousName = this.$target[0].querySelector('.s_website_form_input').name; [...this.$target[0].childNodes].forEach(node => node.remove()); @@ -1336,6 +1338,10 @@ options.registry.WebsiteFieldEditor = FieldEditor.extend({ this._deleteConditionalVisibility(fieldEl); } } + const newInputEl = this.$target[0].querySelector('input'); + if (newInputEl) { + newInputEl.dataset.fillWith = dataFillWith; + } }, /** * Sets the visibility dependency of the field. diff --git a/addons/website/static/tests/tours/website_form_editor.js b/addons/website/static/tests/tours/website_form_editor.js index 5159ed82f63..c3ff35ad6f7 100644 --- a/addons/website/static/tests/tours/website_form_editor.js +++ b/addons/website/static/tests/tours/website_form_editor.js @@ -140,6 +140,12 @@ odoo.define('website.tour.form_editor', function (require) { content: "Complete Recipient E-mail", trigger: '[data-field-name="email_to"] input', run: 'text_blur test@test.test', + }, { + content: 'Edit the Phone Number field', + trigger: 'input[name="phone"]', + }, { + content: 'Change the label position of the phone field', + trigger: 'we-button[data-select-label-position="right"]', }, ...addExistingField('email_cc', 'text', 'Test conditional visibility', false, {visibility: CONDITIONALVISIBILITY, condition: 'odoo'}), @@ -317,6 +323,10 @@ odoo.define('website.tour.form_editor', function (require) { content: 'Verify value attribute and property', trigger: '.s_website_form_field:eq(0) input[value="John Smith"]:propValue("Mitchell Admin")', }, + { + content: 'Verify that phone field is still auto-fillable', + trigger: '.s_website_form_field input[data-fill-with="phone"]:propValue("+1 555-555-5555")', + }, // Check that if we edit again and save again the default value is not deleted. { content: 'Enter in edit mode again',