protected function Formatter::getFieldOptions in Select (or other) 8.3
Retrieves an array of options available for this field.
Return value
array A Key -> Value array of available options.
1 call to Formatter::getFieldOptions()
- Formatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ Formatter.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ Formatter.php, line 51 - Contains \Drupal\select_or_other\Plugin\Field\FieldFormatter\Formatter.
Class
- Formatter
- Plugin implementation of the 'select_or_other' formatter.
Namespace
Drupal\select_or_other\Plugin\Field\FieldFormatterCode
protected function getFieldOptions() {
$field_options = [];
if ($this
->getSetting('available_options')) {
$field_options = explode("\n", $this
->getSetting('available_options'));
$pos = strpos($this
->getSetting('available_options'), '|');
if ($pos !== FALSE) {
$temp_options = [];
// There are keys.
foreach ($field_options as $field_item) {
$exploded = explode('|', $field_item);
$temp_options[$exploded[0]] = $exploded[1];
}
$field_options = $temp_options;
}
}
return $field_options;
}