My filepicker
dropdown fields aren’t being populated with the list of page media as expected.
These troublesome filepickers are inside a list
containing the elements
field type.
Here’s a snippet from my page blueprint:
header.content_blocks:
type: list
style: vertical
fields:
.type:
type: elements
label: "Content Type"
size: small
default: image
options:
image: Image
...
fields:
image:
type: element
fields:
.file:
label: Select Image from Media
type: filepicker
folder: self@
preview_images: true
...
I’ve noticed that the documentation for elements only includes text fields.
Is this a known limitation with the element
field type?
Further info:
- The filepicker dropdown is empty when I select it.
- I get a “Not Found” error flash up when loading the page in admin.
- Other
filepicker
fields work correctly outside of the list (ie: header.image
works; the list of page media is shown when I click on the dropdown).
– Text fields inside the elements field are working as expected.
- If I move the
.file
to the root level (ie: header.file
) OR outside of the elements field (ie: header.content_blocks.file
) it works as expected. So the blueprint seems to be valid, it just doesn’t work when it’s inside the elements field type.
- I’ve tried the
on_demand
option for the filepicker (no luck).
- Similar thing (data not loading) is happening with other dynamic fields using
data-options@
which might be related.
1 Like
I’m experiencing a very similar issue. Been wrestling with it for a white because it always almost seems to work.
I’m trying to make a list of image slides with a elements in each giving options for image src (custom_URL, current_page_media, first_uploaded, all_media)
Using MediaPicker works fine, and pagemediaselect as a field works anywhere else but once it’s inside an element it breaks with 404 errors.
Only work around for me is to show all options normally instead of within an organized elements field.
Anyone else experiencing this? Any reason a pagemediaselect shouldn’t work inside an elements element?
1 Like
Hi !
If anyone is still looking for an answer, I think I just found one.
The declaration of the field path of the element must be done “absolutely” and not “relatively” from the parent field. Please note that the absolute/relative namind is more of a reflexion of mine than an absolute truth;
This is working
because the field path is absolute
header.is_archive.type:
type: elements
label: Mode archive
default: false
options:
non: Non
oui: Oui
fields:
oui:
type: element
fields:
header.is_archive.oui.background_image: # Here we are passing the complete path of the field
type: filepicker
folder: 'self@'
preview_images: true
label: Image de fond
on_demand: true
this is not working
: the field path is relative to the parent field
header.is_archive.type:
type: elements
label: Mode archive
default: false
options:
non: Non
oui: Oui
fields:
oui:
type: element
fields:
.background_image: # the path of the field is declared "relatively" to the parent field
type: filepicker
folder: 'self@'
preview_images: true
label: Image de fond
on_demand: true
With the working version the stored data looks like this:
is_archive:
type: oui
oui:
background_image: nzp67pm9dgbe1.gif