getgrav / grav-plugin-admin

Grav Admin Plugin
http://getgrav.org
MIT License
355 stars 227 forks source link

dot in blueprint key #2280

Open dani-ooo opened 2 years ago

dani-ooo commented 2 years ago

i’m making a blueprint for collections for @page.pages only, as a list field like so:

header.content.items:
  type: list
  fields:
    .@page.page:
      type: pages

but this produces:

content:
  items:
    -
      '@page':
        page: /slug

which then doesn’t work for the templates.

i’ve tried different ways of escaping it, getting different results, but none of them working. a couple of examples:

content:
  items:
    -
      '''@page':
        'page''': /slug
content:
  items:
    -
      '''[@page':
        page: /slug
content:
  items:
    -
      '[@page':
        page: /slug

doing it as a single value field, with header.content.items.@page.page / header.content.items[@page.page], gives similar results.

is this the intended behavior? is there a way to achieve this, or a workaround?

mahagr commented 2 years ago

Umm, that looks wrong. What are you trying to do? The collections are defined by data, not by blueprint.

dani-ooo commented 2 years ago

the blueprint is for the form to ask for the data, so say the first code i’m referring to is in /blueprints/pages/collection.yaml, and the result i’m talking about is in /pages/slug/collection.md.

mahagr commented 2 years ago

Alright. So you need to implement this in a bit different way. Maybe use the list field where you can choose the key and value / list of values.

dani-ooo commented 2 years ago

yeah, no. i tried that too before, but the array field doesn’t allow multiple values with the same key; so, if i try to add multiple @page.pages, only the last one in the list is saved. and i also would like the user to be able to just select a page from a list — the array field consists of textfields only.

either way, i believe the problem i’m presenting here is something that should be addressed?

mdestafadilah commented 2 years ago

yeah, no. i tried that too before, but the array field doesn’t allow multiple values with the same key; so, if i try to add multiple @page.pages, only the last one in the list is saved. and i also would like the user to be able to just select a page from a list — the array field consists of textfields only.

either way, i believe the problem i’m presenting here is something that should be addressed?

you want dropdown select instead textfields?

hughbris commented 1 year ago

Duplicate of #783?