Skip to content

Commit

Permalink
[5.x] Cast to Array to Resolve Issues with Filters Returning `EntryCo…
Browse files Browse the repository at this point in the history
…llection` (#10627)

Co-authored-by: Jason Varga <[email protected]>
  • Loading branch information
SylvesterDamgaard and jasonvarga authored Aug 14, 2024
1 parent c4f5f7b commit bd21b00
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Fieldtypes/HasSelectOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Statamic\Fieldtypes;

use Illuminate\Support\Collection;
use Statamic\Facades\GraphQL;
use Statamic\Fields\LabeledValue;
use Statamic\GraphQL\Types\LabeledValueType;
Expand All @@ -25,6 +26,10 @@ protected function getOptions(): array
{
$options = $this->config('options') ?? [];

if ($options instanceof Collection) {
$options = $options->all();
}

if (array_is_list($options) && ! is_array(Arr::first($options))) {
$options = collect($options)
->map(fn ($value) => ['key' => $value, 'value' => $value])
Expand Down

0 comments on commit bd21b00

Please sign in to comment.