I’m trying to pass data entered into two dropdowns to another page once a button is hit. In this case I have the makes and models of cars on the ‘home page’ which can be selected.
I thought I could have done something to default the dropdown value to the choice selected on the previous page but have had no luck.
Appears I’m trying to default a dropdown which has the ‘type of choices’ set as a ‘grouping’. In this thread they were able to get a dropdown working where the type of choices were ‘text’ - Dropdown default value
I created a ‘cache’ thing so that upon the search bar being hit, a cache ‘Make’ and ‘Model’ will be saved against the user’s profile but it didn’t appear to make a valid default query
Hi there, @bowdo… since you are showing the dropdowns again on the Make page, it seems to me that you could simplify the whole thing by eliminating the first page altogether. If you don’t want to go that route, then saving a user’s selections when they click the search button is one way to carry the selections over to the second page, but it’s not clear to me what you mean by the cache thing you created. Is that a custom data type in which you have fields for the make and model a user selected? Or are the make and model fields directly on the User data type? Also, what type of fields are make and model on the Car data type? Some screenshots of your overall setup would probably help here.
Thanks for reaching out Mike - good idea to keep everything on the one page
Yes the cache I was referring to was a custom data type used to save the dropdown option from the 1st page and place it in the 2nd page by using the ‘default value’ setting on the dropdown. You will see a few ‘C-Make’ and ‘C-Model’ fields against different ‘things’ in my attempts to see if there was a way to pass the data from 1 page to the next by using a different data type. Bubble appears to be expecting the default value to be passed as a ‘grouping’ which is the part I haven’t been able to solve i.e. how do I pass a Make to the Default Value setting when a grouping has been used
When the search button on the 1st page is pressed, the Make and Model if entered will get saved to the ‘cache’ custom data type - with the intention of using that data to populate the 2nd dropdown. I’m also starting to think it’s not a good option to use this design, given it would require a user to be logged in for the dropdown options to save and be defaulted. Perhaps I need to re-evaluate how to go about this
Hmm, I see a few things… first. I don’t think you need to use a grouping for your choices source for the dropdown. Can’t you do something like Search for Cars:each item's Make:unique elements? Next, you created a Cache data type, but you aren’t creating a new thing in that data type when the search button is clicked. Instead, you are saving the dropdown values to fields on the User data type. So, you could get rid of the Cache data type because it isn’t doing anything (I think you could also get rid of the C-Make and C-Model fields on the Car data type, too). Finally, if you get rid of the grouping for the dropdown’s choices source, I believe a default value for the dropdown of Current User's C-Make will produce the desired result.
Also noticed everything works as inteded even when a user isn’t logged in, as Bubble must save data against an anonymous user when not logged
Key takeaways:
You can de-duplicate a list of options using ‘unique elements’ opposed to ‘group by’. See ‘choices source’ field in screenshots.
When you can’t query on a custom data type, you can potentially try querying on the data type of a particular field such as ‘text’. See ‘type of choices’ field
If you have workflow that saves data against a user, but no user is currently logged in, Bubble saves that data against an anonymous user so the workflow can still work