The Choice component allows us to select an option from a predefined list.
The choice component requires two columns from your sheet:
- A list of choices (Apples, Oranges, Pears... etc)
- A column where the choice will be recorded for each list item
We can pre-populate the second column with default choices that people can override.
Here's a detailed explanation:
Let's imagine that we want to record what people's favorite food is.
Step 1: Create a sheet which has different people in our rows.
Step 2: On a separate tab of your spreadsheet, create another column with unique options users will be able to choose from.
Step 3: Back in Glide, add your choice component and make sure Sheet and Values fields are connected to where your options are located in your Google Sheet. Then make sure that the Column field (under Data) is connected to the column where you want the choices to be recorded.
Step 4: (optional): If you want your list items to have default values, rather than being blank - pre-populate the cells with whichever choice you want to appear as default. This is of course overridable by users.
If your list of choices is over 9 items then a search bar will automatically be added to allow people to search the different choices.
Optionally, we can have the choice component record different values to our sheet than the ones that are displayed in the app by using the Display As property.
For example in our sheet we have two columns in our options sheet: Food and Food code.
If we wanted our Choice component to write the Food Code to our sheet but display the Food name in the app, then we can select Food Code for the Value and Food as the Display as option.
Now when users choose their favorite food, our sheet will receive that food's specific code - rather than the name of the fruit.
There are many reasons why you might want to do this. Perhaps your values are too long to display in a choice component, or maybe the values you want the choice to add to your sheet are actually image links that don't display in the image component.
Design & Options
Under Design, we can add a Title to our Choice component. In addition to this we can select from four options for our Design:
- Radio Buttons
Under Options, we can set our Choice component to be Required, so if we are using a Form for example, the user will not be able to submit unless they've selected one of the options. We can also limit the number of items displayed.