I have projects with awards in a structure field.
I want to have a list of all awards grouped by their date.
In Kirby 2 this worked:
Blueprint project.yml
title: Projekt
fields:
...
awards:
label: Auszeichnungen
type: structure
fields:
title:
label: Auszeichnung
type: text
required: true
date:
label: Datum
type: date
required: true
format: DD.MM YYYY
controller:
<?php
return function ($site, $pages, $page) {
$projects_with_awards = page('projekte')
->children()
->filterBy('template', 'project')
->filterBy('awards', '!=', '');
$tmp = [];
foreach ($projects_with_awards as $project) {
foreach ($project->awards()->toStructure() as $award) {
if($award->date()) {
$tmp[] = [
'title' => $award->title()->value(),
'date' => $award->date()->toDate('%Y'),
'project' => $project,
];
}
}
}
$projects = new Collection($tmp);
$projects = $projects->sortBy('date','desc')->groupBy('date');
return compact('projects');
};
now I get this error:
Invalid grouping value for key: 4
Any ideas how to fix this?