Global Array for select Field

I am trying to build a select field in a project that feeds from the values of an array in config.php.

This works also so far. But why are the label values stored in the .txt file of the project and not the values?

Or: Why does my select field in the values also get the capitalized texts?

config.php

'technique-map' => [
	'malerei' => 'Malerei',
	'zeichnung' => 'Zeichnung',
	'mischtechnik' => 'Mischtechnik',
	'monotypie'  => 'Monotypie',
	'digital' => 'digital'
],

project.yml

technique:
  label: Technik
  type: select
  options: query
  query: kirby.option("technique-map")

HTML-Output in the panel:

<select id="1273" name="technique" class="k-select-input-native">
  <option value=""> — </option>
  <option value="Malerei"> Malerei </option>
  <option value="Zeichnung"> Zeichnung </option>
  <option value="Mischtechnik"> Mischtechnik </option>
  <option value="Monotypie"> Monotypie </option>
  <option value="digital"> digital </option>
</select>

Theoretically, I can work with it. But what I actually hoped for is to have the possibility to change the descriptions of the values later if necessary.

So now it is like this:
malerei => Malerei

But in the future I might want to rename it to
malerei => Malerei mit Pinsel

For this i hoped to store “malerei” into my project.txt and not “Malerei”

Or how can I solve this differently so that I can conveniently rename categories of a select field later without having to reassign my projects?

Thanks for any help!

You can set value and text like this:

      technique:
        label: Technik
        type: select
        options: query
        query:
          fetch: kirby.option("technique-map")
          text: "{{ arrayItem.value }}"
          value: "{{ arrayItem.key }}"

Thanks. That was what i am searching for! Nice. Wonderful. You made my day :wink:

Could you please help me to get the value from the array?

i have page.technique as value and need to get the value from the global array

does not work:

{{ kirby.option("technique-map").page.technique }}

works (but is not dynamic)

{{ kirby.option("technique-map").malerei }}
// echoes: "Malerei"

Where are you doing this? What are those curly braces, some template language?

In standard php:

$map     = kirby.option("technique-map");
$malerei = $map[$page->technique()->value()];

i am in blueprints/sections/projects.yml to get the “technique” in my panel card

I’d create a custom method or page model method that return the correct value.