Prepopulating inputs with data questoin

Hi all -

Wanted to get some opinions on how I might pre-populate address information in a form. Here’s the set up. I have a simple input for address that currently pre-populates from a search box the google map address into respective elements. So the information contained in the fields below the search is prepopulated with the search content into the respective fields below

However, if the user has ALREADY chosen an address and wants to modify/edit anything I want it to alternatively prepopulate with what has already been entered. Then, if the map search content is different, it can overwrite what already exists (e.g. the first attempt at inputing). But I don’t want to save multiple addresses – just the final or last saved one.

So, in short, is there a way to prepopulate with the search infromation as I am doing if there is nothing saved in the database already, but to prepopulate with what is in the database if there IS something there.

Does this make sense at all?

Sure! I would use :defaulting to. Looks like those are text inputs, and you can say something like

Search for user-specific record, pull record information stored in the db :defaulting to → pull the google search results, this for every box. It’s a bit more complex but without knowing what your setup is I can’t be more precise. Hope this helps!

1 Like