I'm submitting a ... (check one with "x")
[ ] bug report => Search github for a similar issue or PR before submitting
[X] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Plunkr Case
http://plnkr.co/edit/GuEdxXOOClLs2RoeExJd?p=preview
Current behavior
Field 'value' from SelectItem is set in ngModel / FormControl.
When using an object array as options (#4274) the object is set instead.
Expected behavior
Since we already have optionLabel when using an object array as options, it would be greatly appreciated if we could define an optionValue in order to select a field of the object instead of the whole object (id for example).
What is the motivation / use case for changing the behavior?
Being able to use an array of objects as options for Dropdown and similar components but still be able to set only one of the object fields as the input value.
FWIW: I was able to workaround this by using/modifying the method located in ObjectUtils.
generateSelectItems(items: any[], label: string, value?: string): SelectItem[] {
let selectItems: SelectItem[] = [];
if(items && items.length) {
for(let item of items) {
selectItems.push({label: this.objectUtils.resolveFieldData(item, label), value: value ? this.objectUtils.resolveFieldData(item, value) : item});
}
}
return selectItems;
}
This way you can pas in an Object[] and specify both the label and the value.
is there any option to set string to dropdown value instead of passing entire object?
any ETA on this, can I make a pull request to fix it? thanks in advance
same issue in autocomplete
You can find it implemented here in the meantime, I'll try to keep my branch up to date:
https://github.com/yelhouti/primeng/releases/tag/8.0.0-rc2
is the new feature not yet deployed ?
Hello @yelhouti this can already be used from the version 8.0.0?
primeng team refused to merge my PR, so I deployed it in my fork, to use it, use this instead of the version number in your package:
"primeng": "https://github.com/yelhouti/primeng/releases/download/8.0.0-rc2/primeng-8.0.0-rc.2-SNAPSHOT.tgz",
I do not understand, there are many issus open with this same request and several people would certainly use this feature and yet the primeng people do not give us answers or accept implementations. Why that @cagataycivici ??
some news @cagataycivici ?
@yelhouti, did the prime team provide any explanation while refusing your PR?
yes: company policy
Although the project is opensource, it is not community driven, only employees can add new features.
PS: still the best angular component library in my opinion
PS 2: even tough they don't accept them, I make a PR every now and then hopping one of them pass, a version with all my fixes is here: https://github.com/yelhouti/primeng/ check the readme for the list of fixes/features
@cagataycivici thanks for assigning this, you people rock!
Please check this PR: https://github.com/primefaces/primeng/pull/7279
It already fixes the problem, I would gladly add some tests/documentation wherever needed
PrimeReact and PrimeVue has optionValue so PrimeNG will get it in 9.0.1 as well.
Applies to Dropdown, MultiSelect, SelectButton and Listbox
Moved to 9.1.0 as 9.0.x is for maintenance and 9.1.x is for new stuff like this, new Galleria, Virtual Scroll Tree...
Any ETA for this please? just wondering to know when to upgrade my fork :) thanks
9.1.0 is already packed with features and enhancements and this issue deserves more attention so moving to PrimeNG 10 which is not too far away.
Thanks cagataycivici,
It's a really important feature. We need to do lot of hacks to work around it. This is very basic thing missing. Looking forward to PrimNG10
so i have nothing left to say after all this time we have been waiting for this tiny little feature but u wont accept the PR also u wont do it urself so tell us please what to do in this case !
Hey all, scheduled for 10.1.0, this one has high priority.
@cagataycivici https://github.com/primefaces/primeng/pull/9359
I really welcome this change. I hadn't realised that you can intercept the change by using ControlValueAccessor. So I created a small example on Stackblitz where you can see that: https://stackblitz.com/edit/primeng-autocomplete-demo-t47r9j
Maybe it'll help someone until we get this.

we are waiting for the new version
@cagataycivici will the feature be available for Auto complete components as well? I saw the tagging for SelectButton, Multi select and list box. Thanks
@cagataycivici I hope you are well, I am on version 10 of PrimeNG and I have tried everything that works, bring the value (id) of the object and I tried this last change that you showed in your image but it does not work, this was already released in the last version ?
same here v10 but optionValue is not a valid attribute of p-dropdown ??
I even looked throw the source code and optionValue is nowhere to be found , but the docs says I can use it ???
Ok Its working in version 11
Most helpful comment
PrimeReact and PrimeVue has optionValue so PrimeNG will get it in 9.0.1 as well.
Applies to Dropdown, MultiSelect, SelectButton and Listbox