Ing
Ing

Reputation: 611

How to add a label after a field (Odoo 14)

I got an error when trying adding label after a field .

  <div>
       <field name="percentage" class="oe_inline"/>
       <label string="%" class="oe_inline"/>
    </div>

Any help? Thanks.

Upvotes: 0

Views: 4688

Answers (2)

CorneliusLe
CorneliusLe

Reputation: 41

This can be done by using a div and two label elements. For example, like this:

<group style="width:25%">                       
  <label for="percentage" string="Percentage"/>
  <div class="o_row">                         
    <field name="percentage"/>                
    <label for="percentage" string="%"/>      
  </div>                                      
</group>                                        

Upvotes: 3

Kenly
Kenly

Reputation: 26748

The label tag must contain a for. You should see the following error:

Label tag must contain a "for". To match label style without corresponding field or button, use 'class="o_form_label"'.

Try to set the label for attribute to percentage or use a span to show the % after the percentage field value.

Upvotes: 6

Related Questions