Change text printed in Select field

Hello, everyone,
Where can I edit the text that is printed in the drop-down menus to select a related object?

image

In this case it is only printing the ref, I would like to find the function that defines what to use as a label

I found the solution.
Go to your objectname.class.php file, at the top of the file there is an array $fields in which all the fields are defined.
In the field you want to appear in the dropdown menus add ‘showoncombobox’=>‘1’ and you’re done.

this method will probably disappear when you upgrade Dolibarr

That’s probably true, if you do this on one of the dolibarr core objects and update you lose this change, but the argument applies to any change you make to the dolibarr code base. The fact remains that I don’t think there is in fact another way (although some objects have this list formatted in particular ways, i think somewhere there is something that allows this but it is not documented).

In my specific case, however, I am using a module that I am building myself so it is not directly modified by dolibarr updates.

If you know a better method (or the correct method, if there is one) please share it.

Ciao,
I happened to change the attributes of an object’s fields after instantiating it.

$object = new MyObject($db);
$object->fields[MyField][showoncombobox] = 1

I don’t know if this is your situation, but I would try to include something similar in your module
Marcello