Skip to content

FieldtypeRepeaterPorter::importConfigData() does not apply fields’ context data #2252

@romaincazier

Description

@romaincazier

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions