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

How to change the value used from the AJAX response? #160

Open
ChangePlaces opened this issue Oct 19, 2019 · 2 comments
Open

How to change the value used from the AJAX response? #160

ChangePlaces opened this issue Oct 19, 2019 · 2 comments

Comments

@ChangePlaces
Copy link

I see 'text' is required in the AJAX response to show. How can I change this to a different value from 'text', to 'foo'? Maybe it could be a property on the form type?

@tetranz
Copy link
Owner

tetranz commented Oct 19, 2019

The id and text names are a select2 requirement. https://select2.org/data-sources/formats

There is no way to change it for now but I think it would be possible to enhance the templating functionality to provide a simple means to use a different property name. I can't make any promises but I agree that it would probably be a useful feature.

@ChangePlaces
Copy link
Author

ChangePlaces commented Oct 20, 2019

with select2 v.3 you could override the selection method and return the property you want to use. in 3 it was formatSelection and formatResults iirc. It looks like they've been renamed to templateSelection and TemplateResults for 4.*.

https://stackoverflow.com/questions/23643409/in-select2-how-do-formatselection-and-formatresult-work

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

2 participants