I have a primevue Select that accepts a key value pair for the label/value:
<FloatLabel variant="on">
<Select
id="edit-array"
v-model="formData.arrayChoice"
:options="optionsArray"
optionLabel="label"
optionValue="value"
dropdown
fluid
/>
<label for="edit-array">Select Option</label>
</FloatLabel>
// form data that is set on page load from the DB in another spot in the code
const formData = ref({
arrayChoice: '',
etc
})
const optionsArray = computed(() => {
return options.map((op) => ({
value: op.value,
label: op.label
})
)
})
This properly displays the options when I click the dropdown and it correctly sets the value when the associated label is chosen, however the previously set option isn’t displayed when the form first loads.
formData.arrayChoice
is analogous to optionsArray
‘s value
so I was expecting the label
that’s selected to match the one associated with the value
but it never does, it’s just a blank dropdown until something is selected. What am I missing?
I did also confirm that formData.arrayChoice is correctly set on page load (as the dropdown value
)