I recently moved a production Yii2 app to a new virtual machine. The old VPS was a CentOS on GoDaddy and the new one is an Ubuntu 22.04 VM running on an internal ESXi host. The Yii version on the VPS is 2.0.23 and on the VM it's 2.0.47.
The only problem so far is with the FullCalendar extension: philippfrenzel/yii2fullcalendar. Both VMs use the same version 3.9.0, but the new VM does not render the calendar widget properly.
It's a pretty straightforward setup. The view code:
<?= \yii2fullcalendar\yii2fullcalendar::widget([
'events' => $events,
'id' => 'home-calendar',
'clientOptions' => [
'eventClick' => new JsExpression($js_event_click),
],
]);
?>
The controller action:
$homeEvents = HomeEvent::find()->all();
$events = [];
foreach ($homeEvents as $homeEvent) {
$event = new Event([
'id' => $homeEvent->id,
'title' => $homeEvent->title,
'allDay' => ($homeEvent->all_day == "T"),
'start' => $homeEvent->start_dt,
'end' => $homeEvent->end_dt,
'editable' => true,
'className' => ($homeEvent->all_day == 'T') ? 'fc-event-allday' : null,
]);
$events[] = $event;
}
...
return $this->render('homepage', [
'events' => $events,
...
]);
There are 2 other hosts where this widget is running as expected, on an Ubuntu 14.04 VM and my MacOS Ventura test computer. PHP version is 5.6 on all 4 hosts.
Any ideas?
So, I narrowed it down to the allDay boolean property in the Event model. The documentation says that this property "affects whether an event's time is shown."
If I don't include the property at all, the calendar renders correctly, except that the "all day" events all start with time: 12a (midnight), like this:
If I set the allDay property to true for these events, the time goes away, but the events render incorrectly, as in my OP above.
(I did view every YouTube tutorial I could find on FullCalendar/PHP integration, but none use the allDay property in their examples.)
Anyway, coded a CSS workaround in the view that displays the calendar. I know that this code would be better suited in assets but I consider it a temporary fix for now.
<?php
$style = <<< CSS
.fc-event-allday .fc-content .fc-time {
font-size: 0;
}
CSS;
$this->registerCss($style);
It appears that FullCalendar adds the class="fc-event-allday" tag when it sees midnight 00:00:00 in the start time portion, even if the AllDay property is omitted (assumed false).
Not elegant, but it works.
PS. I don't know if philippfrenzel/yii2fullcalendar has been abandoned, but he has not replied to the issues page in GitHub in several years. The latest "stable" release is 4.0.2, but most commenters agree that 3.9.0 is the most current working version.