Skip to content

Commit

Permalink
NEW convenience methods for getting / setting the value of an extrafi…
Browse files Browse the repository at this point in the history
…eld (Dolibarr#29856)

* NEW convenience methods for getting / setting the value of an extrafield on an object

* Update htdocs/core/class/commonobject.class.php

[code formatting] removing extra space
  • Loading branch information
atm-florianm authored Jun 9, 2024
1 parent 5a4d80a commit 7163299
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7213,6 +7213,29 @@ public function updateExtraField($key, $trigger = null, $userused = null)
}
}

/**
* Convenience method for retrieving the value of an extrafield without actually fetching it from the database.
*
* @param string $key Name of the extrafield
* @return mixed|null
*/
public function getExtraField($key)
{
return $this->array_options['options_'.$key] ?? null;
}

/**
* Convenience method for setting the value of an extrafield without actually updating it in the database.
*
* @param string $key Name of the extrafield
* @param mixed $value Value to be assigned to the extrafield
* @return void
*/
public function setExtraField($key, $value)
{
$this->array_options['options_'.$key] = $value;
}

/**
* Update an extra language value for the current object.
* Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
Expand Down

0 comments on commit 7163299

Please sign in to comment.