MDL-82481 reportbuilder: re-use existing method for field options.

This commit is contained in:
Paul Holden 2024-07-15 17:35:57 +01:00
parent fd487cd3f2
commit c2d73d6e53
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164

View File

@ -237,12 +237,7 @@ class custom_fields {
// Options are stored inside configdata json string and we need to convert it to array.
if ($field->get('type') === 'select') {
$filter->set_options_callback(static function() use ($field): array {
$options = explode("\r\n", $field->get_configdata_property('options'));
// Method set_options starts using array at index 1. we shift one position on this array.
// In course settings this menu has an empty option and we need to respect that.
array_unshift($options, " ");
unset($options[0]);
return $options;
return $field->get_options();
});
}