Debugging fields

I followed @tideg’s excellent description of how to use routs and a son file to provide structure data from other pages in a multiselect: How to query nested structure-field into multiselect-field

My JSON generating code works:
http://localhost:8000/xxxx/yyyy/components.json gives me a json file for that combination of xxxx and yyyy.

Now if I use the multiselect here in a structure on page yyyy (the data for the multiselect is in on page xxxx):

component:
  type: multiselect
  label: "Components"
  options: api
  api:
    url: "{{ site.url }}/{{ page.parent.slug }}/{{ page.slug }}/components.json"
    text: "{{ item }}"
    value: '"{{ item.key }}":"{{ item }}"'
  multiple: true
  empty: "No components selected"

I get the error message ”Illegal offset type in isset or empty” inline as a field, which for me means my url is likely wrong. Is there any way to see the parsed URL? That would help in not trouble shooting this in a trial-and-error way.

Could you post the structure of your JSON please?

Sure!

{"1":"Main Component","2":"Secondary Component","3":"Test","4":"Test 2"}

I think. the problem is that you are trying to server it under a page folder, try another route, like

'pattern' => 'myapi/components.json'

Then in your blueprint

 url: "{{ site.url }}/myapi/components.json"

Well, that won’t work for me as I have different json files under different projects. And the generation of the json file works OK. I cannot use another folder as the “parent.page.slug” and the “page.slug” are both input variable into the generation of the JSON file.

If the multiselect has no awareness (apart from site.url?) of where it is in the page hierarchy, it might be impossible to do what I want it to do. (Which is fine, I just wished there was an easy way to display how Kirby interprets queries used in field strings.)

I couldn’t get it to work using page, so I guess this is not implemented.

As to debugging this, I don’t know of a good way to do that.

Thanks for confirming. Let’s see how I can work around of that…