Where did you get this code? ChatGPT? It loads options but this is never passed to the input, so the input naturally won’t show them.
But why would you create a custom field Vue component in the first place just to feed some custom options? The default select field allows for that out of the box from a lot of different sources (incl. API): Select | Kirby CMS
Hi, thanks for the feedback @distantnative . I want to populate the field based on the selected value of another select field. As far as I understand, this is not possible with the default select field. Or is it?
I want the user to choose a page and then offer options from that page. Basically allow them to choose a block from another page. And use this as a reference. So they don’t have to copy the block.
Sorry for the code I was in the middle of trying around. But my understanding of the Vue components is still very limited.
Sorry, i do not get it. The dynamic options seem all only be possible directly from another field, so for example I can split a value and display it. But can I have a query with a filter based on the value of another field in the block? I do not see an example of how to use another field in a query.
What I want is something like this to be able to select a block (id):
# this works:
query: site.find('home').layout.toLayouts.toBlocks
text: "{{ block.type }}"
value: "{{ block.id }}"
# but how to do this?
query: site.find(this.selectedPage).layout.toLayouts.toBlocks
# or
query: site.find(block.selectedPage).layout.toLayouts.toBlocks
And how would I update/refresh the values when the selectedPage field changes?
Ok, slowly I start to understand what you are trying to do. This indeed won’t work as especially unsaved changes are not available on the server yet (stored in the browser) and thus the query language has no access to what you just selected in your other field.
You will indeed need a custom component for that (say field B), which tries to get the value of field A from this.$store.getters['content/values'](), sends this a custom API, retrieves back the possible options.
Where your initial example fails is that you retrieve options form the API, but you don’t pass/bind them to the input, there you only pass the props ($props).
@distantnative I got it all working apart from my last question about getting the field value from the same block and at the moment I always get the previous value.