439
edits
(→Storing extra options: Changed from object to associative array) |
|||
| Line 125: | Line 125: | ||
Eg: | Eg: | ||
<source lang="php"> | <source lang="php"> | ||
$extra = | $extra = array(); // $extra should always be an associative array, it's no longer an object | ||
$extra | $extra['myproperty'] = 'Anything I want here'; // set a property/extra option like this | ||
$extra | $extra['category']['subcategory']['prop'] = true; // we can set recursive properties, there's not any limit to how deep the hierarchy can be | ||
require_once(DOL_DOCUMENT_ROOT.'/customfields/class/customfields.class.php'); | require_once(DOL_DOCUMENT_ROOT.'/customfields/class/customfields.class.php'); | ||
| Line 135: | Line 135: | ||
</source> | </source> | ||
You can also use addCustomField() or updateCustomField() with an $extra | You can also use addCustomField() or updateCustomField() with an $extra array, and these functions will also call the setExtra() method. | ||
'''Note''': the extra options you set are '''appended''' to the | '''Note''': the extra options you set are '''appended''' to the ones already stored in the database. However, you can also overwrite previous options, just use the same name of property but with a different value (the replacement is recursive, you can do it at any level in the hierarchy). | ||
=== Fetching extra options === | === Fetching extra options === | ||
edits