mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 09:59:06 +01:00
LSformElement_supannLabeledValue: improve API mode
This commit is contained in:
parent
c533aecc34
commit
c87f609610
1 changed files with 23 additions and 0 deletions
|
@ -209,4 +209,27 @@ class LSformElement_supannLabeledValue extends LSformElement {
|
|||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retreive value as return in API response
|
||||
*
|
||||
* @param[in] $details boolean If true, returned values will contain details if this field type
|
||||
* support it (optional, default: false)
|
||||
*
|
||||
* @retval mixed API value(s) or null/empty array if no value
|
||||
*/
|
||||
public function getApiValue($details=false) {
|
||||
$values = array();
|
||||
foreach(ensureIsArray($this -> values) as $value) {
|
||||
$decodedValue = $this -> parseValue($value);
|
||||
if (is_array($decodedValue)) {
|
||||
$values[] = ($details?$decodedValue:$decodedValue['value']);
|
||||
}
|
||||
}
|
||||
if ($this -> isMultiple()) {
|
||||
return $values;
|
||||
}
|
||||
if (!$values)
|
||||
return null;
|
||||
return $values[0];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue