Recently, I've been working with a FormulateInput select component that looks like this:
<FormulateInput
name="broj_zns-a"
@change="setZns"
:value="brojZnsa"
type="select"
label="Broj ZNS-a*"
validation="required"
:validation-messages="{required: 'Ovo polje je obavezno'}"
:options="this.brojeviZnsa"
:placeholder="this.brojeviZnsa.length > 0 ? 'Odaberite' : 'Nema podataka'"
/>
The options for this component are obtained from an API and structured as follows:
let brojeviZnsa = res.data.map(zns => ({
'value': zns["zns_unos_podataka_broj_znsa"],
'label': zns["zns_unos_podataka_broj_znsa"],
'id': zns["id"],
}));
this.brojeviZnsa = brojeviZnsa;
One issue I have encountered is the inability to fetch the "id" of the selected option in the change event handler:
setZns(e) {
this.getZns(e.target.value);
},
While e.target.value provides the value of the current selection, I actually require the "id" for the getZns function.
I did attempt using e.target.id, but unfortunately, it returns undefined.
I appreciate any assistance you can offer on this matter!