#save dropdown values in modalforms?

1 messages · Page 1 of 1 (latest)

sharp plume
#

Ah, so using a number would make this easier then. How exactly do you want to save the index you get out of the form?

#

I meant like, do you want to use a scoreboard, some sort of database, dynamic properties, ect, but dynamic properties would probably be easiest for this

mint halo
#

I'll just drop my approach here:

let options = player.getDynamicProperty("savedOption");
options = options ? JSON.parse(options) : []
const ui = new ModalFormData()
.dropdown('Label1',["blue","red","green"],options?.[0]??0)
.dropdown('Label2',["water","fire","wind"],options?.[1]??0)
.show(player).then(response=>{
    player.setDynamicProperty("savedOption",JSON.stringify(response.formValues));
    //other code
})
sharp plume
#

They aren't trying to save all of the form values.?

#

Just the dropdown responses

mint halo
#

Or you know... you can just save it to different properties as integers.

#

alright fine, decimal.

#

Or Number

#

Which one do you like?

#

fair enough.

sharp plume
#

I was just gonna say do player.setDynamicProperty("chatColorIndex", data.formValues[3]) to save the value
and then to get it to set the default use player.getDynamicProperty("chatColorIndex") ?? null 🤷‍♂️

mint halo
#

that's the basic idea of how my approach is tho.

sharp plume
#

It should yes

mint halo
#

Oh well, anything works in the end. So it doesn't matter.

sharp plume
#

Yeah, they could refactor there code to not use tags, but even if they do it'd probably make more sense to save each number as it's own dynamic property than to save one json string dynamic property 🤷‍♂️ this is their code though so they're free to do it how they like

#

Sweet

#

Hm?

#

I don't follow?

#

What are you considering the default value the dropdowns reset to?

mint halo
#

Maybe you put the wrong number in?

#

did it run the setDynamicProperty?