Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options type API not working with .slug Query #5020

Closed
isaactopo opened this issue Jan 24, 2023 · 4 comments
Closed

Options type API not working with .slug Query #5020

isaactopo opened this issue Jan 24, 2023 · 4 comments
Assignees
Labels
type: regression 🚨 Is a regression between versions
Milestone

Comments

@isaactopo
Copy link

Description

I have updated to Kirby 3.9 and I have a Nationality custom field for the users blueprint as follows:

nationality:
  label: Nacionalidad
  type: select
  translate: false
  options:
    type: api
    url: https://raw.githubusercontent.com/Dinuks/country-nationality-list/master/countries.json
    text: "{{ item.en_short_name }}"
    value: "{{ item.en_short_name.slug }}"

As you can find on the forum: https://forum.getkirby.com/t/options-type-api-not-working/27672/7
When not using .slug for the value, is all working as expected but when using it the select only gets the latest item:

panel image

This is explained on the docs:
https://getkirby.com/docs/reference/panel/fields/select#options-via-api

It's a Bug or we can't use .slug for the API queries and it's a documentation thing?

This is the JSON I’m using:
https://raw.githubusercontent.com/Dinuks/country-nationality-list/master/countries.json

My setup

Kirby Version 3.9.0

  • Device: MacBook Pro M1 Pro
  • OS: macOS Ventura 13.1
  • Browser: Brave/Chrome

Thanks!

@afbora
Copy link
Member

afbora commented Jan 24, 2023

Not sure but I think field method usages for query calls not for api 🤷‍♂️
https://github.com/getkirby/kirby/blob/3.9.0/src/Option/OptionsApi.php#L118

@texnixe
Copy link
Member

texnixe commented Jan 24, 2023

@isaactopo mentioned in the linked forum thread that it worked in versions prior to 3.9, in which case it would be a regression, but I haven't verified yet.

If it never worked, then this example in the docs is not correct, it currently doesn't work either.

category:
  label: Category
  type: select
  options:
    type: api
    url: https://example.com/companies.json
    query: Companies
    text: "{{ item.name }}"
    value: "{{ item.name.slug }}"

@texnixe
Copy link
Member

texnixe commented Jan 24, 2023

In 3.7.5, this works fine

fields:
  nationality:
    label: Nacionalidad
    type: select
    options: api
    api:
      url: 'https://raw.githubusercontent.com/Dinuks/country-nationality-list/master/countries.json'
      text: "{{ item.en_short_name }}"
      value: "{{ item.en_short_name.slug }}"

So I would expect this to work also in 3.9.

@texnixe texnixe added the type: regression 🚨 Is a regression between versions label Jan 24, 2023
@distantnative distantnative self-assigned this Feb 25, 2023
@distantnative distantnative added this to the 3.9.2 milestone Feb 25, 2023
@distantnative
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression 🚨 Is a regression between versions
Projects
None yet
Development

No branches or pull requests

4 participants