I try to build an events-page and the events should have the possibility to enter multiple dates.
For the event-child-page i use the new entries-field with a date field and tried to get it to work with this two topics:
$consolidatedEvents->add($recurringEvent) stores the page under its ID as the collection key, so adding the same event again just overwrites the previous entry. Use append() with a unique key instead, e.g.
Hmm, I think you keep adding the same page object in the loop, so setEventDate overwrites it every time and all of them end up with the last date. Try cloning the page for each date:
Also, if the template is event-recurring, shouldn’t the class be EventRecurringPage instead of EventsPage? Or am I missing something. And you can add a getter to read the date:
class EventRecurringPage extends Page
{
protected $eventDate;
public function eventDate()
{
return $this->eventDate;
}
public function setEventDate($date)
{
$this->eventDate = $date;
}
}
Then $event->eventDate() works in your snippet, and sortBy('eventDate') too.