Migu Posted March 17 Share Posted March 17 Hello, As soon as I try to add a RepeaterField inside another RepeaterField, I receive the warning message: "Undefined array key 'fields_id'" in ...\wire\core\WireSaveableItemsLookup.php:115. After refreshing the page, the message disappears. However, when I add a text field to a RepeaterField, I do not encounter this issue. Below, you can see the function I am using. Can anyone tell me what I am doing wrong? Thanks! Miguel protected function createRepeaterField($repeaterName, $repeaterFields, $repeaterLabel , $repeaterTags='') { // Create Field $f = new Field(); $f->type = wire('modules')->get("FieldtypeRepeater"); $f->name = $repeaterName; $f->label = $repeaterLabel; $f->tags = $repeaterTags; $f->save(); //Create fieldgroup $repeaterFg = new Fieldgroup(); $repeaterFg->name = "repeater_$repeaterName"; $repeaterFg->save(); // Erst speichern! //Add fields to fieldgroup foreach($repeaterFields as $field) { $repeaterFg->append(wire('fields')->get($field)); } $repeaterFg->save(); //Create template $repeaterT = new Template(); $repeaterT->name = "repeater_$repeaterName"; $repeaterT->fieldgroup = $repeaterFg; $repeaterT->save(); //Setup page for the repeater $repeaterPage = "for-field-{$f->id}"; $f->parent_id = wire('pages')->get("name=$repeaterPage")->id; $f->template_id = $repeaterT->id; //Now, add the fields directly to the repeater field foreach($repeaterFields as $field) { $repeaterFieldIds[] = wire('fields')->get($field)->id; } $f->repeaterFields = $repeaterFieldIds; $f->save(); return $f; } 1 Link to comment Share on other sites More sharing options...
elabx Posted March 17 Share Posted March 17 Instead of setting the repeater parent page "for-field-{$f->id}", can you try calling: $f->type->getRepeaterParent($f); Link to comment Share on other sites More sharing options...
elabx Posted March 17 Share Posted March 17 You can also try doing: $f->type->getRepeaterTemplate($f) to create the repeater template. Link to comment Share on other sites More sharing options...
Migu Posted March 17 Author Share Posted March 17 Thanks, but that didn’t solve my problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now