diff --git a/addons/web/static/src/views/form/form_compiler.js b/addons/web/static/src/views/form/form_compiler.js
index fa91858e63d..234d63f0eda 100644
--- a/addons/web/static/src/views/form/form_compiler.js
+++ b/addons/web/static/src/views/form/form_compiler.js
@@ -70,13 +70,6 @@ export class FormCompiler extends ViewCompiler {
}
createLabelFromField(fieldId, fieldName, fieldString, label, params) {
- const props = {
- id: `'${fieldId}'`,
- fieldName: `'${fieldName}'`,
- record: `props.record`,
- fieldInfo: `props.archInfo.fieldNodes['${fieldId}']`,
- className: `"${label.className}"`,
- };
let labelText = label.textContent || fieldString;
if (label.hasAttribute("data-no-label")) {
labelText = toStringExpression("");
@@ -86,7 +79,11 @@ export class FormCompiler extends ViewCompiler {
: `props.record.fields['${fieldName}'].string`;
}
const formLabel = createElement("FormLabel", {
- "t-props": objectToString(props),
+ id: `'${fieldId}'`,
+ fieldName: `'${fieldName}'`,
+ record: `props.record`,
+ fieldInfo: `props.archInfo.fieldNodes['${fieldId}']`,
+ className: `"${label.className}"`,
string: labelText,
});
const condition = label.getAttribute("t-if");
@@ -372,7 +369,20 @@ export class FormCompiler extends ViewCompiler {
const groupClassExpr = `scope && scope.className`;
if (isComponentNode(slotContent)) {
- if (getTag(child, true) !== "button") {
+ if (getTag(slotContent) === "FormLabel") {
+ mainSlot.prepend(
+ createElement("t", {
+ "t-set": "addClass",
+ "t-value": groupClassExpr,
+ })
+ );
+ combineAttributes(
+ slotContent,
+ "className",
+ `(addClass ? " " + addClass : "")`,
+ `+`
+ );
+ } else if (getTag(child, true) !== "button") {
if (slotContent.hasAttribute("class")) {
mainSlot.prepend(
createElement("t", {
diff --git a/addons/web/static/tests/views/form/form_compiler_tests.js b/addons/web/static/tests/views/form/form_compiler_tests.js
index 1e116f06ac8..956ff99af4b 100644
--- a/addons/web/static/tests/views/form/form_compiler_tests.js
+++ b/addons/web/static/tests/views/form/form_compiler_tests.js
@@ -54,7 +54,7 @@ QUnit.module("Form Compiler", (hooks) => {