Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoComplete v-model on specific field #355

Closed
ochiers opened this issue Jul 1, 2020 · 12 comments
Closed

AutoComplete v-model on specific field #355

ochiers opened this issue Jul 1, 2020 · 12 comments

Comments

@ochiers
Copy link

ochiers commented Jul 1, 2020

Hello,

I want to use the autoComplete component with complex object like suggestions.
But I need to bind the model on a specific field of the suggestion only.

We can specify the field to display selection but i need to bind on other field.

For example, a user with id and name, we want to display the name and autocomplete on it but the binding is on the id of the user.

Sincerely

@west-farmer
Copy link

west-farmer commented Jul 2, 2020

My idea is using computed field sync simple var with selected object, or watching the selected object

@cagataycivici
Copy link
Member

Yes, that would work. If there are more requests, we may consider adding props like optionLabel, optionValue like the select components to AutoComplete.

@darmanovic
Copy link

darmanovic commented Jul 4, 2022

I would also like to see this option. Strange that you haven't implemented it.

Example: I've list of objects but need only ID field as v-model.

@vcmenezes
Copy link

I would also like to see this option.

@JuanRomanRiquelme
Copy link

i aldo need this, was there no update lately?

@InToSSH
Copy link

InToSSH commented Nov 1, 2022

+1 would love to see this too. I switched from Vuetify where this was working, you could specify the prop for label and for value, then you could also switch if you want to return just the value prop (for example id) or the whole object, which was really useful. Now I need to create my custom wrapper for the Autocomplete to do this.

If anyone finds it useful, here is my wrapper for the AutoComplete: Github gist

It accepts an array of objects with props 'label' and 'value' in the 'items' prop and returns just the value of selected object in the wrapper's v-model, it also converts the 'value' prop of the v-model passed to the wrapper back into object and feeds it to AutoComplete.

@mklueh
Copy link

mklueh commented Jun 17, 2023

Would be really nice to have that option. I'm basically transforming my Vue model to query parameters immediately, and having an object instead of the value inside it will create city=[object+Object].

@kstan79
Copy link

kstan79 commented Aug 27, 2023

ya ya, autocomplete + v-mode databinding need that so badly. Please support optionValue

@sshkpp
Copy link

sshkpp commented Mar 12, 2024

I agree! I need optionValue props.

@YuriOsipov
Copy link

I agree! I need optionValue props as well

@frasza
Copy link

frasza commented Jul 3, 2024

Cmon, please? :) @cagataycivici

@kstan79
Copy link

kstan79 commented Jul 4, 2024

Base on my understanding autocomplete not design as prefetch all value. In that case autocomplete very hard to obtain label and value separately. If you need that you shall use dropdown, or create separate component, perform deeper engineering, play with emits to modify achieve the goal. I'm using primevue auto complete but I have similar requirement with you, with more complex requirement so I created own customize component on top of autocomplete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests