Get date from structur field for a select in panel

I’m trying to retrieve a unique value (specifically a title) that I’ve set within a structured field, in order to use it as the value for a <select> dropdown. The goal is to extract this value reliably so it can be used for dynamic selection or filtering purposes.

Like if there is set Color, Font → I want to have in the select the options.

attributSelect:
        label: Eigenschaft für Auswählen
        type: select
        options: query
        query:
          fetch: page.variants.toStructure
          text: "{{ structureItem.technicaldata.toStructure.pluck('title').unique.join(', ') }}"
          value: "{{ structureItem.technicaldata.toStructure.pluck('title').unique.join(', ') }}"

   variants:
        label: Varianten
        type: structure
        fields:
          title:
            label: Titel
            type: text
          shortdescription:
            label: Kurzbeschreibung
            type: textarea
          description:
            label: Beschreibung
            type: textarea
          technicaldata:
            label: Technische Daten
            type: structure
            fields:
              title:
                label: Titel
                type: text
              data:
                label: Wert
                type: text

Maybe someone can give me a hint :slight_smile:

Ok, if I understand this correctly, you want to get the data from the nested structure field technicalData. What you are trying to do there won’t work for several reasons, though:

  1. There is no unique method, would be pluck('title', true) to get only unique values
  2. There is no join method.
  3. pluck returns an array, not a collection, so you cannot call any method on it.

Is that some hallucinated code from ChatGPT?

What you need to do here is create a custom page method or model, where you have more options to directly return an array of options from this nested structure. This method you would then use in the query.

Nope - I just put an idea I had. :slight_smile:
Oky. I will try it over custom page method.