Just for other peoples reference I've been using @adrian's coding here:
as a function in my module:
protected function createRepeater($repeaterName,$repeaterFields,$repeaterLabel,$repeaterTags, $icon){
$f = new Field();
$f->type = $this->modules->get("FieldtypeRepeater");
$f->name = $repeaterName;
$f->label = $repeaterLabel;
$f->tags = $repeaterTags;
$f->icon = $icon;
$f->repeaterReadyItems = 3;
//Create fieldgroup
$repeaterFg = new Fieldgroup();
$repeaterFg->name = "repeater_$repeaterName";
//Add fields to fieldgroup
foreach($repeaterFields as $field) {
$repeaterFg->append($this->fields->get($field));
}
$repeaterFg->save();
//Create template
$repeaterT = new Template();
$repeaterT->name = "repeater_$repeaterName";
$repeaterT->flags = 8;
$repeaterT->noChildren = 1;
$repeaterT->noParents = 1;
$repeaterT->noGlobal = 1;
$repeaterT->slashUrls = 1;
$repeaterT->fieldgroup = $repeaterFg;
$repeaterT->save();
//Setup page for the repeater - Very important
$repeaterPage = "for-field-{$f->id}";
$f->parent_id = $this->pages->get("name=$repeaterPage")->id;
$f->template_id = $repeaterT->id;
$f->repeaterReadyItems = 3;
//Now, add the fields directly to the repeater field
foreach($fieldsArray as $field) {
$f->repeaterFields = $this->fields->get($field);
}
$f->save();
return $f;
}
// usage
public function install(){
$fields = array('title','body');
$this->createRepeater("text_repeater",$fields,"Text repeater","", "file-text");
}