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

Select components in version 11, cannot bind to object only to property. #9671

Closed
aznarepse opened this issue Dec 17, 2020 · 2 comments
Closed

Comments

@aznarepse
Copy link

I'm submitting a ... (check one with "x")

[ x ] bug report => Search github for a similar issue or PR before submitting
[ ] 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

Current behavior
When using a select component, such as Dropdown, the selection is limited to a property of the object only but cannot be the whole object.
The issue #9505 discloses that there is a breaking change affecting the templates. However, it also affects how the selection is bound to the control, which now with version 11 only gets a property. This breaks all the submits that before where accepting an object and performing logic with them.

Expected behavior
If the parameter optionValue is not set, the whole object should be bound to the control as it was with version 10.

What is the motivation / use case for changing the behavior?
Breaks all the existing API POST calls in forms.

Please tell us about your environment:
Running in linux with a nginx server.

  • Angular version: 11

  • PrimeNG version: 11

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    Chrome, Firefox, and IE latest versions

  • Language: all

@aznarepse
Copy link
Author

Furthermore, the problem lies within the method (in primeng-dropdown.js)
getOptionValue(option) { return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : (option.value !== undefined ? option.value : option); }

Since all the objects that we use are implementing an interface in the form:

    {
        id: number,
        value: string,
        display: string,
        description: string
    }

the above function assumes that the value is the property 'value'.

If I am arbitrarily and explicitly defining which property is the value, then such property should be the value, otherwise, it should be the object and not a default magic property... If I wanted 'value' to be the value, I would use optionValue="value".

@antsteyer
Copy link

Linked to #9660

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

3 participants