Skip to content

Commit

Permalink
[5.x] Avoid collections in dictionary fields fieldtype (#10579)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga authored Aug 6, 2024
1 parent cbb1f97 commit d446b3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Fieldtypes/DictionaryFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ public function preload()
return [
'type' => [
'fields' => $typeField->toPublishArray(),
'meta' => $typeField->meta(),
'meta' => $typeField->meta()->all(),
],
'dictionaries' => Dictionary::all()->mapWithKeys(function (\Statamic\Dictionaries\Dictionary $dictionary) {
return [$dictionary->handle() => [
'fields' => $dictionary->fields()->toPublishArray(),
'meta' => $dictionary->fields()->meta(),
'meta' => $dictionary->fields()->meta()->all(),
'defaults' => $dictionary->fields()->all()->map(function ($field) {
return $field->fieldtype()->preProcess($field->defaultValue());
}),
})->all(),
]];
}),
})->all(),
];
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Fieldtypes/DictionaryFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function it_returns_dictionary_fields_in_preload()
'fields' => [
['handle' => 'type', 'type' => 'select'],
],
'meta' => collect(['type' => null]),
'meta' => ['type' => null],
],
], $preload);

Expand All @@ -39,10 +39,10 @@ public function it_returns_dictionary_fields_in_preload()
'fields' => [
['handle' => 'category', 'type' => 'select'],
],
'meta' => collect(['category' => null]),
'defaults' => collect(['category' => null]),
'meta' => ['category' => null],
'defaults' => ['category' => null],
],
], $preload['dictionaries']->all());
], $preload['dictionaries']);
}

#[Test]
Expand Down

0 comments on commit d446b3b

Please sign in to comment.