I'm trying to setup some Global fields in a migration.
I'm using the SuperTable Field from verbb which is similar to a matrix field.
I'd like to add several rows during migration but can't seem to get the combination right in order to set the field values. Can someone help me out, what I've got so far is the following:
$globalSet = Craft::$app->globals->getSetByHandle("myGlobals");
$globalSet->setFieldValues([
'siteName' => "The Website",
'siteCustom' => [
'new1' => [
'type' => 'superTableBlockType',
'fields' => [
'firstField' => "some value",
'secondField' => "some other value"
]
]
]
]
);
Craft::$app->globals->saveSet($globalSet);
SuperTable::$plugin->servicewithSuperTable::$plugin->getService(). And in my special case I had to pass in a context toCraft::$app->getFields()->getFieldByHandle('fieldHandle', false)(I just passedfalse) because I am dealing with a SuperTable field within a MatrixBlock instead of a standalone SuperTable field. Works like a charm! Thanks. – Arvid May 16 '23 at 14:04