private function fixBlockFieldsForPreview($record)
    {
        foreach ($record->contenttype['fields'] as $fieldSlug => $fieldSettings) {
            if ($fieldSettings['type'] === 'block') {
                $fieldValue = $this->getBlockFieldValue($record, $fieldSlug);
                if ($fieldValue) {
                    $newArray = [];
                    foreach ($fieldValue as $item) {
                        if (!empty($item)) {
                            foreach ($item as $k => &$v) {
                                $v['block'] = $k;
                            }
                            $newArray[] = $v;
                        }
                    }
                    $this->setFieldValue($record, $fieldSlug, $newArray);
                }
            }
        }

        return $record;
    }
private function fixBlockFieldsForPreview($record)
    {
        foreach ($record->contenttype['fields'] as $fieldSlug => $fieldSettings) {
            if ($fieldSettings['type'] === 'block') {
                $fieldValue = $this->getBlockFieldValue($record, $fieldSlug);
                if ($fieldValue) {
                    $newArray = [];
                    foreach ($fieldValue as $item) {
                        if (!empty($item)) {
                            foreach ($item as $k => &$v) {
                                $v['block'] = $k;
                            }
                            $newArray[] = $v;
                        }
                    }
                    $this->setFieldValue($record, $fieldSlug, $newArray);
                }
            }
        }

        return $record;
    }
private function fixBlockFieldsForPreview ( $ record ) { foreach ( $ record -> contenttype [ 'fields' ] as $ fieldSlug => $ fieldSettings ) { if ( $ fieldSettings [ 'type' ] === 'block' ) { $ fieldValue = $ this -> getBlockFieldValue ( $ record , $ fieldSlug ) ; if ( $ fieldValue ) { $ newArray = [ ] ; foreach ( $ fieldValue as $ item ) { if ( ! empty ( $ item ) ) { foreach ( $ item as $ k => & $ v ) { $ v [ 'block' ] = $ k ; } $ newArray [ ] = $ v ; } } $ this -> setFieldValue ( $ record , $ fieldSlug , $ newArray ) ; } } } return $ record ; }
Helper function to prefill `block` fields with an additional `block` field per item.

This is needed to make previewing content with block fields fully working.
Helper function to prefill block fields with an additional block field per item .