Complementary Attributes / Custom fields... howto

Hello everyone,

I’ve just started (two months ago) with dolibarr and sometimes I have some problems finding a path to what I want to modifiy. I need some custom fields on my Invoices, so I was planning to use this “Complementary attributes” on the Setup for Invoices. I thought doing some small changes on the PDF templates (PHP) would be easy.
But surprise, I cannot find anything on the wiki about “Complementary attributes” and I see that there is something called “Custom Fields” so the information is not clear. Somwhere there is a lack of consistence on the Dolibarr “language”, or it is just me who reads on different places /forums / documentation and I missed something.

Would be this the correct workaround? https://wiki.dolibarr.org/index.php/Module_CustomFields#Implementing_in_PDF_templates , and if so, is there somewhere an easier guide?

Thank you very much!

There is a write-up in wiki - https://wiki.dolibarr.org/index.php/Extrafields#Display_extrafield_value_into_PDF_or_HTML
I guess “extrafields” and “complementary attributes” are synonymous.

Basically in your pdf template script, you call $object->fetch_optionals() - that would put all the complementary attributes into $object->array_options.
To print out one of the attributes, use $object->array_options[‘options_’ . $key] where $key is the attribute code that you defined.

To print out one of the attributes, use $object->array_options['options_' . $key] where $key is the attribute code that you defined