Skip to content

Commit

Permalink
Fix return values for fluid fields when there are no children
Browse files Browse the repository at this point in the history
  • Loading branch information
bryannielsen committed Sep 26, 2024
1 parent 9edec1b commit 36bacfe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

- Return value for Fluid Field when there are no children

## [1.4.1] - 2024-09-23

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions src/Fieldtypes/FluidField.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ public function apply(FieldContent $content, array $parameters = [])

public function generateGraphType(ChannelField $field)
{
$groupIds = $field->field_settings['field_channel_field_groups'] ?? [];
$fieldIds = $field->field_settings['field_channel_fields'] ?? [];
$groupIds = array_filter($field->field_settings['field_channel_field_groups'] ?? []);
$fieldIds = array_filter($field->field_settings['field_channel_fields'] ?? []);
$fields = collect($groupIds)->reduce(function ($carry, $group) {
return $carry->merge(app(FieldtypeManager::class)->fieldsForFieldGroup($group));
}, collect())->merge(collect($fieldIds)->reduce(function ($carry, $field) {
return $carry->push(app(FieldtypeManager::class)->getField($field));
}, collect()));

$fields = collect($field->field_settings['field_channel_fields'] ?? [])->map(function ($id) {
$fields = collect($fieldIds)->map(function ($id) {
return app(FieldtypeManager::class)->getField($id);
});

$groups = collect($field->field_settings['field_channel_field_groups'] ?? [])->map(function ($id) {
$groups = collect($groupIds)->map(function ($id) {
$fields = app(FieldtypeManager::class)->fieldsForFieldGroup($id);

if ($fields->isEmpty()) {
Expand Down

0 comments on commit 36bacfe

Please sign in to comment.