diff --git a/addons/website_crm/static/src/js/website_crm_editor.js b/addons/website_crm/static/src/js/website_crm_editor.js index a0492d0eee5..361ae783bef 100644 --- a/addons/website_crm/static/src/js/website_crm_editor.js +++ b/addons/website_crm/static/src/js/website_crm_editor.js @@ -13,7 +13,7 @@ FormEditorRegistry.add('create_lead', { name: 'contact_name', string: 'Your Name', }, { - type: 'char', + type: 'tel', name: 'phone', string: 'Phone Number', }, { diff --git a/addons/website_crm/views/website_crm_templates.xml b/addons/website_crm/views/website_crm_templates.xml index c48f6c77472..5ec13993290 100644 --- a/addons/website_crm/views/website_crm_templates.xml +++ b/addons/website_crm/views/website_crm_templates.xml @@ -34,7 +34,7 @@ Phone Number
- +
diff --git a/addons/website_form/static/src/js/website_form_editor_registry.js b/addons/website_form/static/src/js/website_form_editor_registry.js index 82c5f500fab..35acc904eab 100644 --- a/addons/website_form/static/src/js/website_form_editor_registry.js +++ b/addons/website_form/static/src/js/website_form_editor_registry.js @@ -22,7 +22,7 @@ FormEditorRegistry.add('send_mail', { required: true, name: 'Your Name', }, { - type: 'char', + type: 'tel', custom: true, name: 'Phone Number', }, { diff --git a/addons/website_form/static/src/snippets/s_website_form/000.js b/addons/website_form/static/src/snippets/s_website_form/000.js index b06a9b62a74..b71ee1a7d44 100644 --- a/addons/website_form/static/src/snippets/s_website_form/000.js +++ b/addons/website_form/static/src/snippets/s_website_form/000.js @@ -82,7 +82,7 @@ odoo.define('website_form.s_website_form', function (require) { this.$target.find('button').off('click'); // Empty imputs - this.$target.find('input[type="text"], input[type="email"], input[type="number"], textarea').val(''); + this.$target.find('input[type="text"], input[type="email"], input[type="number"], input[type="tel"], input[type="url"], textarea').val(''); // Remove saving of the error colors this.$target.find('.o_has_error').removeClass('o_has_error').find('.form-control, .custom-select').removeClass('is-invalid'); 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 bff1229bf94..7338d64981b 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 @@ -242,7 +242,7 @@ const FieldEditor = FormEditor.extend({ * @returns {HTMLElement} */ _getPlaceholderInput: function () { - return this.$target[0].querySelector('input[type="text"], input[type="email"], input[type="number"] , textarea'); + return this.$target[0].querySelector('input[type="text"], input[type="email"], input[type="number"], input[type="tel"], input[type="url"], textarea'); }, /** * Returns true if the field is a custom field, false if it is an existing field @@ -860,6 +860,11 @@ options.registry.WebsiteFieldEditor = FieldEditor.extend({ await this._replaceField(field); this.rerender = true; }, + selectType: async function (previewMode, value, params) { + const field = this._getActiveField(); + field.type = value; + await this._replaceField(field); + }, /** * Select the display of the multicheckbox field (vertical & horizontal) */ @@ -906,6 +911,8 @@ options.registry.WebsiteFieldEditor = FieldEditor.extend({ return this._getPlaceholder(); case 'selectLabelPosition': return this._getLabelPosition(); + case 'selectType': + return this._getFieldType(); case 'multiCheckboxDisplay': { const target = this._getMultipleInputs(); return target ? target.dataset.display : ''; @@ -920,6 +927,8 @@ options.registry.WebsiteFieldEditor = FieldEditor.extend({ */ _computeWidgetVisibility: function (widgetName, params) { switch (widgetName) { + case 'char_input_type_opt': + return !this.$target[0].classList.contains('s_website_form_custom') && ['char', 'email', 'tel', 'url'].includes(this.$target[0].dataset.type); case 'multi_check_display_opt': return !!this._getMultipleInputs(); case 'placeholder_opt': diff --git a/addons/website_form/static/src/xml/website_form_editor.xml b/addons/website_form/static/src/xml/website_form_editor.xml index 13d4ae1aeb5..ae099e4717c 100644 --- a/addons/website_form/static/src/xml/website_form_editor.xml +++ b/addons/website_form/static/src/xml/website_form_editor.xml @@ -86,7 +86,7 @@ + + + + + + + + + + + + + + + + + + @@ -111,20 +129,6 @@ - - - - - - -