public static function WebformOtherBase::processValue in Webform 8.5
Same name and namespace in other branches
- 6.x src/Element/WebformOtherBase.php \Drupal\webform\Element\WebformOtherBase::processValue()
Processed other element's submitted value.
Parameters
array $element: The element.
array $value: The submitted value.
Return value
array|string An array of values or a string.
1 call to WebformOtherBase::processValue()
- WebformOtherBase::validateWebformOther in src/
Element/ WebformOtherBase.php - Validates an other element.
File
- src/
Element/ WebformOtherBase.php, line 277
Class
- WebformOtherBase
- Base class for webform other element.
Namespace
Drupal\webform\ElementCode
public static function processValue(array $element, array $value) {
$type = static::getElementType();
$element_value = $value[$type];
$other_value = $value['other'];
if (static::isMultiple($element)) {
$return_value = array_filter($element_value);
$return_value = array_combine($return_value, $return_value);
if (isset($return_value[static::OTHER_OPTION])) {
unset($return_value[static::OTHER_OPTION]);
if ($other_value !== '') {
$return_value += [
$other_value => $other_value,
];
}
}
return $return_value;
}
else {
return $element_value === static::OTHER_OPTION ? $other_value : $element_value;
}
}