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

When Submitting Advanced Select with apiUrl the title is submitted instead of the value #481

Closed
x9sim9 opened this issue Oct 14, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@x9sim9
Copy link

x9sim9 commented Oct 14, 2024

Summary

The select submits the title instead of the value when using apiUrl

Steps to Reproduce

https://preline.co/docs/advanced-select.html#remote-data

Using the example provided, its setting the option values like this
<option value="Essence Mascara Lash Princess" data-id="1"

instead of like this
<option value="1" data-id="1"

Demo Link

https://preline.co/docs/advanced-select.html#remote-data

Expected Behavior

<option value="1" data-id="1"

Actual Behavior

<option value="Essence Mascara Lash Princess" data-id="1"

Screenshots

@x9sim9 x9sim9 changed the title When Submitting Advanced Select with apiUrl the title is submitted instead of the value (Fix included) When Submitting Advanced Select with apiUrl the title is submitted instead of the value Oct 27, 2024
@ryansteele
Copy link

Same issue here. Select submits "data-value", which gets set to the apiFieldsMap "title" field. Cannot get select to use the ID for data-value.

In my case, API is returning array of JSON objects in the following format:

{id: "1000420", name: "FM Q3 MENS FALL 1 2025"}

The following option is set for the select:

"apiFieldsMap": { "id": "id", "title": "name" }

The result is:

<div data-value="FM Q3 MENS FALL 1 2025" data-title-value="FM Q3 MENS FALL 1 2025" data-id="1000420">

The expected/desired result would be:

<div data-value="1000420" data-title-value="FM Q3 MENS FALL 1 2025" data-id="1000420">

Or an option to have select submit "data-id" instead of "data-value"

@Root-acess
Copy link

Root-acess commented Nov 1, 2024

In this setup:

The API returns an array of JSON objects, e.g., {id: "1000420", name: "FM Q3 MENS FALL 1 2025"}.

The configuration apiFieldsMap: { "id": "id", "title": "name" } maps the fields, but data-value ends up set to the title instead of the id.

Suggested Solution
Add an option to allow data-value to be mapped to data-id instead of title, so that data-value reflects the id field for submissions. This would improve compatibility for cases where the id field is the preferred submit value.

@jahaganiev jahaganiev added the bug Something isn't working label Dec 4, 2024
@jahaganiev
Copy link
Member

Hey everyone, the issue has been fixed in the latest v2.6.0 release. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants