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

Allow objects to be passed into SelectField #1400

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

unitedsoftwork
Copy link

With this little bit of code we can allow the select field to receive an object rather than just an integer, this is very useful for when a REST API sends nested data rather than just ID's that are references to the data.

e.g

with the field set up like so:

{
     name: "job",
     type: "select",
     items: [*some_array_of_choices*],
     valueField: "id",
     textField: "title",
     title: "Job",
 },

Rather than
{ "id": 1, "name": "John Doe", "job": 1 }
we can now pass something like this
{ "id": 1, "name": "John Doe", "job": { "title": "Manager", "id": 1 } }

@tabalinas tabalinas self-requested a review August 25, 2021 08:12
Copy link
Owner

@tabalinas tabalinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the change!

Could we add a unit test for this new functionality?

@unitedsoftwork
Copy link
Author

ah yes. tests lol.
The test has been written to describe the new functionality.
If you go through with the PR i can update the docs to account for it.

Copy link
Author

@unitedsoftwork unitedsoftwork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here are the tests

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

Successfully merging this pull request may close these issues.

2 participants