Grav-plugin-admin: Multiple Images in pagemediaselect returns 'array'

Created on 7 Jan 2019  路  11Comments  路  Source: getgrav/grav-plugin-admin

header.section.planning.images: type: pagemediaselect multiple: true label: Choose media
I have multiple fieldsets each containing a pagemediaselect.
In each fieldset the user is allowed to add up to X images from the page media pool.

Selecting works fine but when saving the page, all I get is 'array'
image

what am I missing?

1.10 bug fixed in repo

All 11 comments

Seems there's a few 'media' related issues been posted over the holidays. I'll try to dig into them all at the same time when I get caught up with everything.

Can you please provide the full example of your blueprint where the field is defined.

Hi @rhukster , I'm having the same issue. Reproduced in both Grav v1.5.7/Admin v1.8.16, and v1.6.0-beta.8/Admin v1.9.0-beta.8. PHP 7.1.19.

Steps to reproduce:

  1. Create a new page blueprint with a pagemediaselect field and mutiple: true specified
  2. Edit that page in Grav admin, select one or multiple images in the new field
  3. Save page
  4. Observe that both in Grav Admin, as well as the page markdown file, the field contains just the word "Array" rather than a list of files as expected.

Blueprint:
home.yaml.txt

Field before saving page:
image

Field after saving page:
image

Markdown after saving page:
image

Thank you!

Can you try adding

  array: true

to the pagemediaselect field?

If it works, I can easily fix this issue so you don't need to add it manually.

Hey @mahagr

Thanks for the response. Unfortunately no change in behavior after adding array: true

image

There's nothing else I would have to do to get that to "take effect", correct? I did restart the PHP server just in case.

No, that should be all good. I'm starting to think that the field doesn't support multiple, can you send me the resulting yaml file for the data?

Please help how to display multiple images in html twig file

Works just fine for me in Admin 1.9.12. Please reopen if it is still an issue.

Actually I was wrong.

  • Create page type with:
extends@: default

form:
  fields:
    tabs:
      fields:
        image:
          type: tab
          title: Image
          fields:
            header.gallery:
                type: pagemediaselect
                style: vertical
                label: Page Gallery
                multiple: true
  • Create page of this type and add few images
  • Save
  • Add all images to the field
  • Save

Resulting page header:

title: filepicker
media_order: 'file1.png,file2.png,file3.png'
gallery: ''

This works if field has array: true together with multiple: true

Parent field filepicker supports only a single value.

Was this page helpful?
0 / 5 - 0 ratings