[Panel] How to set Select-Fields Default by Query

Hi all,

in a K3.5 i would like to query the data for a select-field from a global structure-field and set the default by the first element of that structure. Unfortenetly that doesn’t work like i want. I would be really happy, if someone can help me here :*

i have a global teaser structure in site.yml

teasers:
  label: Global Teasers
  type: structure
  fields:
    id:
      label: ID
      type: text
      required: true
    teaserh2:
      label: Headline
      type: text
      required: true
    ...

and a selectfield in page-xy.yml, fetching the structure

teaser:
  label: Select from global Teasers
  type: select
  options: query
  query:
    fetch: site.teasers.toStructure
    text: "{{ structureItem.id }}"
    value: "{{ structureItem.id }}"
  default: About
  # default: site.teasers.toStructure.first.id

Unfortenetly i am not able to set the default-value by the id of the first element in the structure.
I have tried several formats. If i hardcode the id, it works - but i need always the first item to be the default.

A second question:

I would like to set text and value of the selectfield-data to lowercase.
Unfortenetly that won’t work also.

teaser:
  label: Select from global Teasers
  type: select
  options: query
  query:
    fetch: site.teasers.toStructure
    text: "{{ structureItem.id.lower }}"
    value: "{{ structureItem.id.lower }}"

All i get then is that:
grafik

What am i doing wrong here?

Thx!

Query syntax is not supported for the default property, I think.

id is a member method of the structureObject, which returns a string.

Try structureItem.content.get('id').lower instead.

I wouldn’t convert the value though (or you have to make sure you find the element by lowercase again).

i think now also :sleepy: tried some other things, but was not successful.

works :+1:

i am going to use autoid - think that is much cleaner than names anyway, but however it is good to know the solution above

thx @texnixe