Call to a member function getName() on null when uploading images

When uploading image/s to page in admin panel error shows up. “Call to a member function getName() on null”
In concole I have this desc:

  1. error: {type: “Error”, message: “Call to a member function getName() on null”, code: 0,…}
  2. code: 0
  3. file: “C:\xampp\htdocs\dev\user\plugins\flex-objects\classes\Controllers\AbstractController.php”
  4. line: 191
  5. message: “Call to a member function getName() on null”
  6. type: “Error”

When I disable plugin Flex-objects everything is ok.
Everything is up to date.

Blueprint only has this special field:
header.img_col:
custom_file:
name: myfile
type: file
label: Foto kolekce
destination: ‘self@’
multiple: true
autofocus: false
accept:
- image/*

Can anybody tell me how to fix it?

@tunkila, I can reproduce the issue…

However, the docs on field file give a clear warning to not use the field file for pages.

The file field is intended to be used by configuration , theme , and plugins blueprints, NOT page blueprints . For pages, you should use the existing pagemedia field and then utilize the filepicker field to select the files.

Field file does indeed work properly in the config blueprint for of theme Quark, but throws the error in a Page blueprint.

The solution offered in above warning is to upload the file using the pagemedia field on the ‘Content’ tab, and use a filepicker in the tab you like. The filepicker will list the file uploaded through the pagemedia field.

header.img_col:
  type: filepicker
  folder: 'self@'
  preview_images: true
  label: Select a file

Thx for your message Pamtbaau.

This is really new behavior (error message) of Grav and new info in Docs to not to use it. I really dont remember that warning from that time I was creating these blueprints (before flex-objects in pages). I have several bigger webpages +2 years old with this functionality and everything was working allright till last week. Its not only about choosing one image but splitting attachements to several headers for forms… (main document + attachements etc.)

Thats why I was asking for help as solution mentioned in Docs is not enought/equal and I know that the problem is much deeper. Filepicker can only choose 1 file not a list (right?).

@tunkila, There are a few issues on Gravs repo about uploading, but they confuse me…

Especially this on from May 2021: File upload fields on page blueprints #3363.

OP is using file field in Page blueprint. Team member doesn’t confirm it shouldn’t work. And it works… back then…

I tried the snippet myself and it errors out.

Update:
I see the team has updated AbstractController on Sept 28: “Use active form from the Form plugin to get page metadata”. This changes the line that is now creating the error. Reverting the commit fixes the issue.

I’ve created a new issue.

@tunkila, Issue has been fixed in flex-objects plugin and released yesterday with Grav 1.7.25