Populate a selectize field with taxonomy options

Hello everyone,

I tried to implement an automatic option populating based on the method proposed here. I added a function in my theme.php and use it in a custom blueprint.
The function is:

  public static function taxonomyValues(string $taxon, string $fieldType)
  {
    /** @var Grav */
    $grav = Grav::instance();

    /** @var Admin */
    $admin = $grav['admin'];
    $admin->enablePages();

    /** @var Taxonomy */
    $taxonomy = $grav['taxonomy'];

    $keys = $taxonomy->getTaxonomyItemKeys($taxon);

    $values = [];

    foreach ($keys as $key) {
      if ($fieldType === 'select') {
        $values[$key] = $key;
      } else {
        $values[] = [
          'text' => $key,
          'value' => $key
        ];
      }
    }
    dump($values);
    return $values;
  }

It works fine with select, but it doesn’t seem to work with selectize. My yaml look like:

header.test:
  type: selectize
  autocomplete: on
  style: vertical
  label: test
  data-options@: ['\Grav\Theme\NixTemplate::taxonomyValues', 'artiste','selectize']
  validate:
    type: commalist

If i dump the $values in the php, I can see an “array of array”:

array:2 [▼
  0 => array:2 [▼
    "text" => "artiste1"
    "value" => "artiste1"
  ]
  1 => array:2 [▼
    "text" => "artiste2"
    "value" => "artiste2"
  ]
]

But if i click in the field in the admin, I can’t see any suggestion of completion, do you know what I am doing wrong?

@nix, I think the field definition isn’t correct. Have a look at the example for the Selectize field in the docs.

Pay attention to how the options attribute is indended below selectize. The data-options@ should replace the options field in the exact same position.

Thanks that was it, I missed the selectize. Here is the working yaml:

header.test:
  type: selectize
  selectize:
    data-options@: ['\Grav\Theme\NixholTemplate::taxonomyValues', 'artiste','selectize']
  autocomplete: on
  style: vertical
  label: test
  validate:
    type: commalist