Select field options

Hello everyone, I created slice named "Gallery" witch contains image and selected field with different values. Is there a way for me to query that select field and get all of it's option values? I couldn't find a solution to accomplish that, thank you in advance !

Hello @mannypa

Welcome to the Prismic community, and thanks for posting this question to us.

You can only query the Select field with one specific value because it returns only the selected value in the API. Here is the complete detail in this article.

I am interested to know more about your use case.


Thank you for your response @Priyanka , maybe i'm doing this wrong, but i would like to get all select field options, so i could filter my gallery images by selected field value. By getting all select options from query i wouldn't have to statically define anything on front end. Maybe my approach isn't right to achieve this ?

Unfortunately, there isn't a quick and easy way to pull all the available options for a Select field from the API.

To do this, it will be a little more complicated, but you have a couple of options.

1. Query all your Articles

The first option is to query all your Article documents, then loop through to collect all the Select options that have been selected.

2. Redo your Select field as Content Relationship

This is a bit more complicated, but you would first need to set up a new Custom Type for the options of your Select field. Then create a new document for each option. Then you need to update your Select field in your Articles to be a Content Relationship field.

You will then need to go into your documents and select the option you need for each one. It might be a lot of work, but in the end, you'd be able to get all the options available in a single query from the API.

This would work a lot as the custom tagging system described here:

‚ÄčCreate a Custom Tagging System

Let me know if you have any doubt.


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.