Get field label in PHP

Hi,

In a custom component I need to display a field label. According to the documentation I can use the "translate" function.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_12.1/Architecture/Languages/Module_Labels/

But the documentation does not mention how to retrieve the label from a module based on a field name. This is what I got so far:

$labelKey = 'LBL_' . strtoupper($fieldName);
$label = translate($labelKey, $module);

This works for most fields, but the system label can be different from the field name, because this is editable when creating a new field.

So what I would like to do is:

$labelKey = getLabelName($fieldName, $module); // THIS FUNCTION DOES NOT EXIST
$label = translate($labelKey, $module);

Regards,

Stijn

Parents
  • You can use app_strings without having to load the whole bean:


    Fullscreen
    1
    2
    global $app_strings;
    $label = isset($app_strings['LBL_THE_LABEL']) ? $app_strings['LBL_THE_LABEL'] : "default_label";
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Francesca,

    Thanks for your reply, but how to get the "LBL_THE_LABEL" in a var this way? I don't know the name of the label.

Reply Children