# Files field empty on panel, but not on content, after programatic update

**URL:** <https://forum.getkirby.com/t/files-field-empty-on-panel-but-not-on-content-after-programatic-update/34489>\
**Category:** Questions\
**Tags:** v4\
**Created:** [July 25, 2025, 10:03pm UTC](https://forum.getkirby.com/t/files-field-empty-on-panel-but-not-on-content-after-programatic-update/34489 "2025-07-25T22:03:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![plagasul](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/plagasul/32/4199_2.png) [@plagasul](https://forum.getkirby.com/u/plagasul)\
**Post date:** [July 25, 2025, 10:03pm UTC](https://forum.getkirby.com/t/files-field-empty-on-panel-but-not-on-content-after-programatic-update/34489/1 "2025-07-25T22:03:23Z")

</div>

Hello,

v4.5 here.

I’ve been programmatically updating `files` fields, and I am having a brain-breaking problem.

I have pages with a files field that:

- Shows visually EMPTY in the panel.
- Is NOT EMPTY in the content file.
- Seems NOT EMPTY when programmatically checking it.
- The file it points at seems to exist when programmatically checking it.

This is the relevant bits of the blueprint declaration:

```auto
title: Publication
(...)
fields:
  cover:
    label: Cover Image
    type: files
    multiple: false 
    size: medium
    layout: cards
    translate: false
    uploads: image

```

This is an example of how I updated the cover field:

```php
  $p->update([
      "cover" => Data::encode([$filename], "yaml"),
  ]);

```

This is the relevant bits of content file for one of these pages:

```auto
Title: 1979 abril-maig

----

Cover: - file://ThGiumUCdevzznrJ

```

This is my debugging code:

```php
  $uuid = $p->cover()->yaml();
  try {
      $file = $p->cover()->toFile();

      if ($file && $file->exists()) {
          echo "✅ Cover file exists: “{$file->filename()}” (UUID: {$uuid[0]})<br>";
      } else {
          echo "❌ toFile() returned null (invalid UUID or no cover set) – stored value: “{$uuid[0]}”<br>";
      }
  }

```

This is the output for this particular page:

```html
1979 abril-maig

✅ Cover file exists: “1979-guino-galeria-trece-web.jpg” (UUID: file://ThGiumUCdevzznrJ)

```

And this is how it looks in the panel, notice the apparently empty “cover” files field:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/3X/2/4/24c89b4f2a0d024d4bdeec86f6e11c765f3d212a.png)

If I click on the field, the image shows with the right title:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/3X/d/3/d38725871d4d0515abffcb38212e6d155963d72c.png)

Aaand, this happens in a LOT of these pages.

Help? 🆘 Thanks 🙂

---

<div class="post-metadata">

**Author:** ![plagasul](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/plagasul/32/4199_2.png) [@plagasul](https://forum.getkirby.com/u/plagasul)\
**Post date:** [July 25, 2025, 10:28pm UTC](https://forum.getkirby.com/t/files-field-empty-on-panel-but-not-on-content-after-programatic-update/34489/2 "2025-07-25T22:28:42Z")

</div>

I ran some additional tests.

Apparently, if I select the file manually in the panel, then the content file shows:

```txt
Cover: - file://R0GMZtJq4lC2X9Sq

```

Which does NOT match the UUIID shown before which was:

```html
✅ Cover file exists: “1979-guino-galeria-trece-web.jpg” (UUID: file://ThGiumUCdevzznrJ)

```

But how could this be? Considering I was extracting that UUID using:

```php
$uuid = $p->cover()->yaml();
$file = $p->cover()->toFile();
echo "✅ Cover file exists: “{$file->filename()}” (UUID: {$uuid[0]})<br>";

```

And now it says:

```html
✅ Cover file exists: “1979-guino-galeria-trece-web.jpg” (UUID: file://R0GMZtJq4lC2X9Sq)

```

Even more confused now.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [July 26, 2025, 5:38am UTC](https://forum.getkirby.com/t/files-field-empty-on-panel-but-not-on-content-after-programatic-update/34489/3 "2025-07-26T05:38:58Z")

</div>

I guess `R0GMZtJq4lC2X9Sq` is then the correct uuid. Not quite clear where the other one comes from, particularly since the code to update the page you posted above is very rudimentary. Does the first UUID `ThGiumUCdevzznrJ` exist anywhere?

---

<div class="post-metadata">

**Author:** ![plagasul](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/plagasul/32/4199_2.png) [@plagasul](https://forum.getkirby.com/u/plagasul)\
**Post date:** [July 29, 2025, 5:43pm UTC](https://forum.getkirby.com/t/files-field-empty-on-panel-but-not-on-content-after-programatic-update/34489/4 "2025-07-29T17:43:29Z")

</div>

Thank you @texnixe

I took the easy option, ignored mismatched outputs, and just bruteforced the right files into the field.

When you say the code is rudimentary, I assume you meant just basic; or did you mean that the code may be wrong or perhaps that there is a better, reccomended, way of updating?

I am, at the moment, attempting to update a pages field, multiple pages, programmatically.

I have an array of uuids of pages, and I am yaml encoding them as such:

```php
$artists = Data::encode($a, 'yaml');
dump($artists);

```

which outputs:

```yaml
- page://IFoC60wFgNzv5G1D
- page://kupN2lsY95eCgFRz

```

Can i then just do?:

```php
$mypage->update([
    'artists' => $artists
]); 

```

Thank you.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [July 29, 2025, 6:09pm UTC](https://forum.getkirby.com/t/files-field-empty-on-panel-but-not-on-content-after-programatic-update/34489/5 "2025-07-29T18:09:00Z")

</div>

> [@plagasul](#):
>
> ```auto
> $p->update([
> "cover" => Data::encode([$filename], "yaml"),
> ]);
> 
> ```

What I meant is that from this piece of code it is not clear what you are doing here, because I do not see how $filename is defined or where this variable is coming from.

Now your second example is just as incomplete, and completely different.

Please post complete code that can be fully reproduced.

---

<div class="post-metadata">

**Author:** ![plagasul](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/plagasul/32/4199_2.png) [@plagasul](https://forum.getkirby.com/u/plagasul)\
**Post date:** [July 29, 2025, 6:28pm UTC](https://forum.getkirby.com/t/files-field-empty-on-panel-but-not-on-content-after-programatic-update/34489/6 "2025-07-29T18:28:39Z")

</div>

Well, it is frankly convoluted code that takes data from a csv and prepares it to be ingested by Kirby’s fields. But simplifying:

```php
$shop = $site->csvToArray(asset("assets/csv/shop.csv")->url());

foreach ($shop as $s) {
    $title = $s["Title"];
    $slug = str::slug($title);
    $artists = $s["Artists"];
    // Content of $artists at this point: ["Bloom, Barbara; Lawler, Louise"]
    // I leave out some code here to turn strings of artists' names in $artists into an array of uuids of already existing 'artist' pages

    $artists = Data::encode($artists, 'yaml');

    // Content of $artists at this point:
    // - page://IFoC60wFgNzv5G1D
    // - page://kupN2lsY95eCgFRz
        
    if (page('publications')->findPageOrDraft($slug)) {
        try {            
            $p->update([
                'artists' => $artists,
            ]);
        } catch (Exception $e) {
            echo $e->getMessage() . '<br />';
        }
    }
}

```

Let me know if any other bit of the code would be necessary, please. Thanks.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [July 29, 2025, 6:58pm UTC](https://forum.getkirby.com/t/files-field-empty-on-panel-but-not-on-content-after-programatic-update/34489/7 "2025-07-29T18:58:27Z")

</div>

Ok, so far so good, but what is the result? Is the data correctly stored in the artists pages field?

---

<div class="post-metadata">

**Author:** ![plagasul](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/plagasul/32/4199_2.png) [@plagasul](https://forum.getkirby.com/u/plagasul)\
**Post date:** [July 29, 2025, 7:19pm UTC](https://forum.getkirby.com/t/files-field-empty-on-panel-but-not-on-content-after-programatic-update/34489/8 "2025-07-29T19:19:45Z")

</div>

I haven’t run this code, my question was if that was the recommendable way of updating a page, but from your answer it would seem so.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [July 29, 2025, 7:27pm UTC](https://forum.getkirby.com/t/files-field-empty-on-panel-but-not-on-content-after-programatic-update/34489/9 "2025-07-29T19:27:24Z")

</div>

> [@plagasul](#):
>
> ```auto
> if (page('publications')->findPageOrDraft($slug)) {
> try {            
> $p->update([
> 'artists' => $artists,
> ]);
> 
> ```

$p is not defined here, so the correct code would be

```auto

 if ($p = page('publications')->findPageOrDraft($slug)) {
        try {            
            $p->update([
                'artists' => $artists,
            ]);
        } catch (Exception $e) {
            echo $e->getMessage() . '<br />';
        }
    }

```
