Friday, September 18, 2020

SugarCRM: Label Placement

Sometimes things happen. Allow me to illustrate.

For a number of years, there has been a little known option within Sidecar view metadata that allowed one to define the placement of field labels relative to the data. You can see the setting defined in line 173 of the snippet pictured below:

Setting the value to false causes the labels to display to the left of the data, as illustrated in the image that follows:

Why would one consider using this feature?

The option has some limitations, but it is helpful for reducing the amount of white space visible to the user. This, in turn, makes the view more compact and allows for more data to be displayed within a given area of the screen. It is also applicable to all users, by default.

Additionally, it is also possible to set the label placement on a per panel or module basis, allowing more granular control over the placement of labels. An example of a per panel configuration is demonstrated below:

Regardless of the manner in which one wishes to implement this feature, it always requires manual intervention, given that the labelsOnTop attribute could not be set through Studio.

The manner in which label placement is defined changed with the release of Sugar 10. 

Sugar 10 introduced a setting that allows a user to determine the manner in which labels are to be displayed. This can be set via the Advanced tab on a user profile, via the preference illustrated in the following image:

This is a user level setting and applies to all modules. That means that the selected preference is applicable to only a specific user, but all the modules that said user can access. To cause all users to view the labels in the same manner, it would be necessary to update this preference for all users. Thus, some measure of control over its application has been retired, but the setting can now be easily set by any user, based on their preference.

Please note that the labelsOnTop attribute is no longer applicable as of Sugar 10. Label placement can only be changed by way of the aforementioned user setting. However, it is possible to customize its applicability by way of a custom RecordView controller (record.js).


  1. Hi Angel, it's funny I was just looking into this feature for a customer who wanted labelsOnTop=true for all users but only for the Accounts module, and was confused when setting the vardef property had no effect! I found that the user preference is retrieved via the getLabelPlacement() method which is defined in clients/base/views/record/record.js. To produce the effect this customer wanted, I just overrode the method in the custom record.js for the Accounts module and set its return value to always be true. This breaks the intended behavior with the preference, obviously. But it met this particular customer's requirement. Hope it's helpful to anyone else investigating this feature :)


Your comments, feedback and suggestions are welcome, but please refrain from using offensive language and/or berating others. Thank you in advance.