grav-plugin-admin
grav-plugin-admin copied to clipboard
filepicker in elements IN a list does not work
While nesting a filepicker (or pagemediaselect) in elements OR list is possible, nesting them in elements IN a list is not. A warning message «Not found» appears in the top right corner. (Tested in Grav v1.7.33 w/ Admin v1.10.33.1)
form:
fields:
tabs:
fields:
content:
fields:
content:
unset@: true
header.list:
type: list
label: List
style: vertical
fields:
.name:
type: text
label: Name
.pagemedia:
type: pagemediaselect
label: Pagemediaselect in List
preview_images: true
.file:
type: filepicker
folder: 'page://images/'
label: Filepicker in List
preview_images: true
accept:
- .jpg
- .png
.type:
type: elements
label: 'Type'
size: small
default: text_only
options:
text_only: Text only
text_and_image: Text and image
fields:
text_only:
type: element
fields:
.text:
type: text
label: Text (One)
text_and_image:
type: element
fields:
.text:
type: text
label: Text (Two)
.file:
type: filepicker
folder: 'page://images/'
label: Filepicker in List in Elements
preview_images: true
accept:
- .jpg
- .png
.pagemedia:
type: pagemediaselect
label: Pagemediaselect in List in Elements
preview_images: true
I've hit this wall just now. I'm attempting to build a similar blueprint with a List > Elements > Element > Filepicker. The error also occurs without the list and just a filepicker field in an elements field.
I'm going to assume if this issue is still open 2.5 years later that there is not a working solution to this setup?
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 :white_check_mark: 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