Skip to content

files field with returnFormat id: a string value in a repeater row crashes the block in the editor #117

Closed

Description

@WebUppAdmin

Summary

A files field with "returnFormat": "id" crashes the block in the editor when the stored value is a string rather than a number or an array. The block shows "This block has encountered an error and cannot be previewed." The front end renders correctly, because the template receives the stored value as documented.

Environment

  • Blockstudio 7.7.1 (also 7.6.14)
  • WordPress 7.1.3, iframed editor
  • PHP 8.5

Setup

A repeater row with a single-image files field:

{
  "id": "items",
  "type": "repeater",
  "attributes": [
    { "id": "image", "type": "files", "allowedTypes": ["image"], "multiple": false, "max": 1, "returnFormat": "id" }
  ]
}

We reference images by a stable name rather than an attachment ID, so that a page file is portable between a staging site and production (IDs differ). The page file sets "image": "buckshair-home"; a filter resolves the name to the attachment on render. With returnFormat: "id" the template receives the string exactly as stored, which is what we need, and the front end is right.

What happens

Opening a page that holds such a block in the editor throws, once per block instance:

TypeError: (intermediate value)(intermediate value)(intermediate value).map is not a function
    at .../blockstudio/includes/admin/assets/blocks/index.tsx.js?ver=6dcbff0c7d82e20929e3:1:1035157

and the block falls back to the error boundary. A multiple files field at the top level of the block holding an array of the same strings ("shots": ["a", "b", "c"]) does not throw: it shows cards with no thumbnail, which is fine. The single field in the repeater row holds the bare string, and the field component calls .map on it.

Suggested behaviour

The field component treats a non-array value as a one-item list (as it already does for a bare attachment ID), and a value it cannot resolve to media as a card with no thumbnail, as the multiple case does. Then a page file can hold a name in a single files field without the editor losing the block preview.

Workaround

Store the single image as a one-item array in the page file, if the field accepts that shape; we are measuring that now. Rewriting every page file for an editor-only shape is the per-project version of the fix above.

Activity

  1. dnnsjsk commented on Oct 15, 2026

    @dnnsjsk
    Contributor

    Fixed and released in Blockstudio 7.7.2, in e8356b83. Single files fields, including repeater rows, now display stored string references as fallback cards without rewriting their values. Removing and reordering cards preserves the other entries. The full CI run passed, including the new editor save/reload and media-selection regression tests.

  2. WebUppAdmin commented on Oct 16, 2026

    @WebUppAdmin
    Author

    Tested on 7.7.2 against our pages on staging this morning: the editor opens clean on every page that names an image in a single files field, and the cards show the name without a thumbnail as you described. No change to what is saved, which is what we needed for the page files to stay portable. Thank you for the fast turnaround on this one too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions