Select field options from Panel API

Hi,

is it not possible to get the options for a select field from a custom Panel API route. I can’t make this work:

Blueprint:

                  option:
                    label: Filter option
                    type: select
                    options: api
                    api:
                      url: "{{ site.url }}/api/filterOptions"
                      text: "{{ item.name }}"
                      value: "{{ item.slug }}"

Route in the plugin:

'api' => [
    'routes' => [
        [
        'pattern' => 'filterOptions',
        'action' => function() {
          return [
            [
              'name' => 'Name 1',
              'slug' => 'slug 1'
            ],
            [
              'name' => 'Name 2',
              'slug' => 'slug 2'
            ],
            [
              'name' => 'Name 3',
              'slug' => 'slug 3'
            ],
         ];
       }
    ]
  ]
],

What am I missing here?

Thank you,
Georg

Can’t make this work, either, maybe it’s not supposed to work.

Okay, I will go with a regular route then.
Would be nice to have this work tough, to have a better distinction between internal and external routes.

The request to the api would need to be authenticated I guess. And there are no credentials sent with the request.

1 Like

@moeli is right. I’ve tried that, too.

The query syntax allows methods of page models and custom methods as well (Query Language). That might be a way to go.

@texnixe Options via API >> This API is not “Kirby API” right?

Exactly, that means you own route or an external API.