439
edits
| Line 414: | Line 414: | ||
=== Find the label === | === Find the label === | ||
Finding the label of a custom field might not be as simple as it seems. First, values of properties objects may be easily used, but their name (key) is a worst job. Secondly, custom fields' labels can be translated, and the following functions are expressly made for that purpose. | Finding the label of a custom field might not be as simple as it seems. First, values of properties objects may be easily used, but their name (key) is a worst job. Secondly, custom fields' labels can be translated, and the following functions are expressly made for that purpose. Thirdly, for PDF and some other documents you have to encode the characters if you want them to properly be drawn. | ||
So if you want to print a custom field's label with translation (multilingual) support, just use the '''findLabel()''' method: | So if you want to print a custom field's label with translation (multilingual) support, just use the '''findLabel()''' method: | ||
<source lang="php"> | <source lang="php"> | ||
$customfields->findLabel(); | $translatedfieldname = $customfields->findLabel($fieldname, $outputlangs = ''); // where $fieldname is just a custom field label (eg: cf_mycustomfield or mycustomfield, both will work) and $outputlangs is the target language object (see the Translate class native of Dolibarr) | ||
</source> | </source> | ||
edits