/** * Prepares the multiple field. * * @param Field $field The field object * @param mixed $data The data */ protected function prepare(Field $field, $data) { if (!is_array($data)) { throw new \InvalidArgumentException(''); } $choices = []; foreach ($data as $index => $value) { $proto = $field->getOption('prototype'); $choice = $this->cloneField($proto); $choice->setInternalName((string) $index); $choice->setParent($field); foreach ($choice->getChildren() as $child) { $child->setParent($choice); } $choices[] = $choice; } $field->setChildren($choices); }