Autocomplete showing value instead of label when selected

Autocomplete showing value instead of label when selected

rozrorozro Posts: 8Questions: 1Answers: 0

Hi, i'm trying to use an autocomplete field type where options are a label->value pair.
When i select a result from the option list, i expect the input shows me the label and "behind" it has the ID saved to be sent.
This does not happens.

Try it here: https://live.datatables.net/holeqaca/3/edit
Create a new item, select an Office and it will show the ID instead of the office name.

It's not cool to show the user the id...

Any way to solve this?
Thank you

Replies

  • allanallan Posts: 65,248Questions: 1Answers: 10,814 Site admin
    edited October 21

    Hi,

    You need to use tags for this - see this example.

    The autocomplete field type is a plain text input - i.e. what is submitted is what is shown. Tags is the solution - it has the ability to show a label that is distinct from the value.

    Allan

  • rozrorozro Posts: 8Questions: 1Answers: 0

    Thank you @allan. I tried and it works as expected.

    I think it should be explained better in docs.

  • allanallan Posts: 65,248Questions: 1Answers: 10,814 Site admin
    edited October 21

    Good to hear that helps!

    I'll add a paragraph to the autocomplete description. Thanks for pointing out that is missing.

    Edit: I've just committed the follow, which will be up on the site with the next deploy:

    Equally, be aware that autocomplete does not use a separate value and label. What is shown in the text box will be the value that is submitted. If you need the form to submit a different value from what is submitted, please use tags, select, or similar.

    Allan

Sign In or Register to comment.