function ListFloatItem::extractAllowedValues
Same name in other branches
- 9 core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php \Drupal\options\Plugin\Field\FieldType\ListFloatItem::extractAllowedValues()
- 8.9.x core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php \Drupal\options\Plugin\Field\FieldType\ListFloatItem::extractAllowedValues()
- 11.x core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php \Drupal\options\Plugin\Field\FieldType\ListFloatItem::extractAllowedValues()
Overrides ListItemBase::extractAllowedValues
File
-
core/
modules/ options/ src/ Plugin/ Field/ FieldType/ ListFloatItem.php, line 69
Class
- ListFloatItem
- Plugin implementation of the 'list_float' field type.
Namespace
Drupal\options\Plugin\Field\FieldTypeCode
protected static function extractAllowedValues($string, $has_data) {
$values = parent::extractAllowedValues($string, $has_data);
if ($values) {
$keys = array_keys($values);
$labels = array_values($values);
$keys = array_map(function ($key) {
// Float keys are represented as strings and need to be disambiguated
// ('.5' is '0.5').
return is_numeric($key) ? (string) (double) $key : $key;
}, $keys);
return array_combine($keys, $labels);
}
return $values;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.