Vue-formulate: Using field type select with options from database. Help me understand how to

Created on 26 May 2020  Â·  2Comments  Â·  Source: wearebraid/vue-formulate

First of all, I really want to thank you all for coming up with this,
I deeply appreciate it is saving me a lot of hours

Just 4 days ago I stumble on this and I am loving it,
I seek help to understand form field Select :options,
My data is coming from database, as an Object/Array/JSON
everything shows up as the first option only,

Illuminate\Support\Collection {#1647 â–¼ #items: array:3 [â–¼ 1 => "Restaurant" 2 => "Social Media" 3 => "Shopping" ] }
JSON
"{"1":"Restaurant","2":"Social Media","3":"Shopping"}"

this is what I get
image

Please appreciate any heads up or better way to do it

Most helpful comment

I'm guessing that the value you're binding into the select list is a string value on the front end and not actually an object.

Try console logging your value and see if it is a JSON string, or a javascript object. You want it to be an object

All 2 comments

I'm guessing that the value you're binding into the select list is a string value on the front end and not actually an object.

Try console logging your value and see if it is a JSON string, or a javascript object. You want it to be an object

@justin-schroeder thank you so much, you got me through

` label="Category"
placeholder="Choose Category"
:options="JSON.parse(this.data.categories)"

`
I really appreciate

Was this page helpful?
0 / 5 - 0 ratings