Dynamically change data fields of an object based on category

I am making a directory of athletes, who play different sports.

I have an Athlete Details object which has these fields.
Name
Age
Country
Sport

And based on the sport he/she plays I need to add a few other fields for each player dynamically.

For example :
if sport is football, he should have football stats like
Total Goals
Total assists
No of yellow cards

and if sport in Running the fields should be
Medals won
Personal record
and so on.

So how do I assign these fields to an athlete object based on the input in the sport field.

Can we do this in bubble ? how can this be handled?

Sure, there’s nothing particularly different or difficult that you need to do here…

Just assign the fields you want to assign, and leave any others blank.

I would assume you’d only want to show the relevant inputs on the page based on the value of the Sport input, so use some conditionals on the subsequent inputs to determine which ones are shown on the page.

Then, in your workflow you can just use a single action to create or modify the thing, which can include all the input’s values.

1 Like

Thanks that helps!

My only concern is, if i have 40 - 50 sport and around 4 -5 fields for each, that would give around 250 data fields in a single object. Will that be fine or is there a better way?

Also in the page where I’m displaying should i have separate groups for each category and then show/hide based on the URL params ? Not sure if this was the right way. Just needed clarification.

In that case it’s probably better to create a separate datatype for each Sport and assign that to an Athlete

i.e. have a datatype for Football_Athlete
With a field for Athlete, and all the other relevant fields for the sport.