After creating a new Repeater field, I’m adding fields like this:
$repeaterField = $fields->newField([
"type" => "FieldtypeRepeater",
"name" => "repeater",
"label" => "My repeater field"
]);
$repeaterField->save();
$repeaterField->type->importConfigData($field, [
"field1" => ["columnWidth" => 50],
"field2" => ["columnWidth" => 50]
]);
However the fields’ context data is not applied. After a quick look at the FieldtypeRepeaterPorter class and a test, it looks like the fieldgroup needs to be saved first before the context, so you would need to replace lines 100-107 by:
if($template) {
if($saveFieldgroup) {
$template->fieldgroup->save();
}
if($saveFieldgroupContext) {
$template->fieldgroup->saveContext();
}
}
Also a quick question: is repeaterFields ever used? It looks like it doesn't make any difference to have it or not in the config data
After creating a new Repeater field, I’m adding fields like this:
However the fields’ context data is not applied. After a quick look at the
FieldtypeRepeaterPorterclass and a test, it looks like the fieldgroup needs to be saved first before the context, so you would need to replace lines 100-107 by:Also a quick question: is
repeaterFieldsever used? It looks like it doesn't make any difference to have it or not in the config data