Work in Progress: How to Create Repeatable Button Components, Fetching from a Database
Note: This page only applies to the Old Rendering Engine - for the New Rendering engine ask a Savvy Expert for help
Repeatable components take data from an array of objects and turn it into the same amount of components.
Step 1: Create and Prepare your Button
Create a button where you want the list of buttons to appear.
Select the component and scroll to the bottom of the Options tab, open the Advanced dropdown.
Select the REPEATER KEY. This will be the key of the Computed field that is fetching the data and returning the array of objects. Here are some docs for reference:
You can also do this on an Option Selector, but you should select from the BUTTON REPEATER KEY
dropdown instead of the REPEATER KEY
dropdown.
Step 2: Transform the Data
You can do this in the same Computed Field as the fetch, but it's a good practice to do it on a different one.
Map it into an object with a 'key' key, and a 'text' key. Something like this:
Try giving it an HTML structure. For example:
Step 3: Style it
Add some classes so you can style it with custom selectors
Here's how to style components with custom selectors:
What if there's more data that I want to show when a user selects one of the options?
Another computed field can easily solve that. The code would look something like this:
This would return the full selected object!
Last updated