Vuetify: Returning objects as values from v-select (multiple) doesn't work

Created on 17 Jul 2017  路  11Comments  路  Source: vuetifyjs/vuetify

Steps to reproduce

  1. Create a v-select with the multiple attribute and add items like { text: 'foo', value: { } } (objects as values)
  2. Select at least two items in the dropdown

Versions

Vuetify 0.14.1
Vue 2.4.1

What is expected ?

The value objects of the selected items should be returned in v-model. This works for me in 0.13.1.

What is actually happening ?

The selection is broken; null values are returned, checked items are not highlighted in the dropdown.

Reproduction Link

https://codepen.io/anon/pen/LLvwmJ

bug

Most helpful comment

Already noted by John, but is a hint for future reference: the prop return-object did the trick for me.

All 11 comments

You were missing your item-value declaration. Since you are using a nested object for it. You were also missing the prop return-object to return the object as the response.

https://codepen.io/johnjleider/pen/jwoNrG

@johnleider Thanks for the quick response.

item-value="value.foo" works but obviously doesn't return the entire object, i.e. it returns test instead of { foo: 'test', bar: 42 }.

return-object will yield the entire item config object which is also not the desired behavior (i.e. { text: 'Item 2', value: { foo: 'test', bar: 42 } } instead of just { foo: 'test', bar: 42 }). Of course you could map the v-model array to get just the value objects, but this worked out of the box in 0.13 (see https://codepen.io/anon/pen/zzQOJX) so I think it's a regression...

Well just because it worked does not necessarily mean it was intended functionality. You said you believe it is a regression, but regression from what? Was there a previous issue that addressed this and was fixed?

In my understanding, the intended behavior is that v-select should return anything that is given in the value prop (if item-value is default) - strings, objects etc. If there are restrictions to this logic, it should be made clear in the docs.

Looking at the code and changes, I was only able to find https://github.com/vuetifyjs/vuetify/commit/d0f81a63286ec63e9dbe7d01964c33e02c7708e7 since the 0.14 release - not sure if it's related, though.

I will take a look at this tonight and see if I'm wrong in my assumptions.

I've went back through this and I was definitely in the wrong. This was functionality changed when we added getObjectByPath. I currently have it working and will push once I write a test.

Thank you for your patience.

Thanks for reconsidering the issue. I'm using this functionality extensively in my app. Keep up the good work with Vuetify!

Create Array of objects where objects like {"text":"Text you want to print in select","value":"set text which you want to set as value"} and bind it to your select items attribute.

Already noted by John, but is a hint for future reference: the prop return-object did the trick for me.

Thank you, beautiful people, for saving me an hour of pulling my hair out. return-object did it for me, too.

@jorr-it thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Webifi picture Webifi  路  3Comments

smousa picture smousa  路  3Comments

dohomi picture dohomi  路  3Comments

KuroThing picture KuroThing  路  3Comments

efootstep picture efootstep  路  3Comments