unionco / calendarize

Calendar Field Type for CraftCMS
MIT License
18 stars 14 forks source link

Can't populate field from console command #90

Open corneliusio opened 3 months ago

corneliusio commented 3 months ago

I'm currently working on a content migration for a large site with a number of events. I've been stuck at trying to populate the Calendarize field on our events section in Craft CMS. After a number of hours not understanding why the field value I was providing simply seemed to silently fail I dug in and found this section of code at vendor/unionco/calendarize/src/services/CalendarizeService.php:308

if (
    !\Craft::$app->request->isConsoleRequest
    && \Craft::$app->request->isPost
    && $value
) {
    $model = new CalendarizeModel($owner, $value);
} else if ($record) {
    $model = new CalendarizeModel($owner, $record->getAttributes());
} else {
    $model = new CalendarizeModel($owner);
}

If I'm understanding the logic flow here, this would seem to mean you could never populate an entry programmatically with calendarize data from a console command at all. Is that correct? Or am I missing something else here?