# Dynamic Structure fields

**URL:** <https://forum.getkirby.com/t/dynamic-structure-fields/26952>\
**Category:** Questions\
**Tags:** v3\
**Created:** [November 4, 2022, 1:59pm UTC](https://forum.getkirby.com/t/dynamic-structure-fields/26952 "2022-11-04T13:59:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![paubou](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/paubou/32/10761_2.png) [@paubou](https://forum.getkirby.com/u/paubou)\
**Post date:** [November 4, 2022, 1:59pm UTC](https://forum.getkirby.com/t/dynamic-structure-fields/26952/1 "2022-11-04T13:59:09Z")

</div>

Hi there,  
I would like to create a structure field to see my website.  
You’d have two columns :  
In the first column you would be able to see or rearrange the categories, and eventually add some more.  
The second column would display the corresponding projects to that category.

When the user creates a new project, they can add a category to it, corresponding to the list in that structure field.  
The strcture field will display the updated corresponding projects in the second column.

I’ve managed to far to guess it will be done using queries. But my select in my individual project (that should display the list from the first column of my structure doesn’t seem ok that I give it an array.)

```auto
fields:
  category:
    label: Category
    type: select
    options:
      type: query
      query:
        fetch: site.find('home').structure.toStructure

```

the query :  
[![](https://i.imgur.com/fcDGmJI.png) ](https://i.imgur.com/fcDGmJI.png)

returns :  
`Kirby\Option\OptionsQuery::__construct(): Argument #1 ($query) must be of type string, array given,`  
Which is obvious, but how to make that work?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 4, 2022, 4:07pm UTC](https://forum.getkirby.com/t/dynamic-structure-fields/26952/2 "2022-11-04T16:07:52Z")

</div>

> [@paubou](#):
>
> ```auto
> type: query
> query:
> fetch: site.find('home').structure.toStructure
> 
> ```

Your syntax is wrong here, looks like you mixed up old with new syntax. When using Kirby 3.8.x, it should be

```auto
fields:
  category:
    label: Category
    type: select
    options:
      type: query
      query: site.find('home').structure.toStructure

```

```auto

```

---

<div class="post-metadata">

**Author:** ![paubou](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/paubou/32/10761_2.png) [@paubou](https://forum.getkirby.com/u/paubou)\
**Post date:** [November 4, 2022, 4:18pm UTC](https://forum.getkirby.com/t/dynamic-structure-fields/26952/3 "2022-11-04T16:18:22Z")

</div>

Alright,  
thanks,  
but actually, this doesn’t seem to change anything;  
here is my `site.yml` blueprint

```nohighlight

title: Site

sections:
  content:
    type: fields
    fields:
      structure:
        label: Structure
        type: structure
        fields:
          Action:
            label: Action
            type: text
      pages:
        label: Projets
        type: pages
        query: site.page("projets").children

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 4, 2022, 4:26pm UTC](https://forum.getkirby.com/t/dynamic-structure-fields/26952/4 "2022-11-04T16:26:00Z")

</div>

If the structure field is in `site.yml` then trying to find the options on the `home` page won’t work. Change your query to … and add the text and value props:

```auto
options:
  type: query
  query: site.structure.toStructure
  text: "{{ item.action }}"
  value: "{{ item.action }}"

```

---

<div class="post-metadata">

**Author:** ![paubou](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/paubou/32/10761_2.png) [@paubou](https://forum.getkirby.com/u/paubou)\
**Post date:** [November 4, 2022, 8:21pm UTC](https://forum.getkirby.com/t/dynamic-structure-fields/26952/5 "2022-11-04T20:21:58Z")

</div>

> [@texnixe](#):
>
> `site.structure.toStructure`

Alright, I get it now, was a bit out of control.  
Thanks a lot.
