Form dropdown based on a string value

  • Goal: define a string value based on a dropdown value in a form

  • Steps: I have a firebase database, with documents that have values as string (ex: city: "paris"). I want to fill this data on edit/create forms with a dropdown, by mapping the value from retool database (I recreated manually a pair of key values)

  • Details: I have my dropdown mapped from cities database, my form data key is "city". But the problem is that when I try to edit an item, the dropdown value stays empty, while I expect it to display the value in my cities database that matches the content of the "city" entry in firebase.

  • Screenshots:
    As you can see in this screenshot, what I expect to see in this dropdown is "Bordeaux"

Hi there @floran and welcome to the forum!

What do you mean when you say,

when I try to edit an item, the dropdown value stays empty

are there no options in the dropdown? Can youright click on your cities query and see the state to see what data is being pulled and potentially send a screenshot?

I've created a tutorial on how to pre populate forms here:

Hopefully it can fill in the gaps of what you need to move forward with your form.

Actually I should have been more explicit : I see the content of the retool database table in the dropdown, as expected. It's just that when I open an item for edition (that already contains a value), I expect it to appear already selected in the dropdown, as the values exist in both places (firebase, as a string, and in the retool table).
I will have a look at your video and see if it can unlock me.

I understood where it comes from: I was using selectedRow (instead of selectedSourceRow), which applies some formatting on the text such as putting everyting first letter in capital, so it was not recognized during the matching between firebase<>retool database.

1 Like

Ah yes, that makes sense. Thanks for sharing what the issue was.

Cheers!