PUGX / PUGXAutoCompleterBundle

Add an autocomplete field to your Symfony forms
GNU Lesser General Public License v3.0
93 stars 38 forks source link

jquery-ui and related json template #68

Closed roburcio closed 3 years ago

roburcio commented 3 years ago

Hello, I'm using autocomplete-bundle with symfony 5 in a form. I'm using the bundle with jqueryui because select2 has accessibility issues for screenreaders. All works fine, but I don'to know how can I solve a problem: In documentation you say that I have to replace id with value using jqueryui. It works but when I'm writing in the field text it shows ids instead labels. When I confirm the choice it shows, correctly, the label. I tried also to put another value with label but it overwrite the first value and I do not have ids anymore. Do you Know how can I solve this problem? Thank you in advance

garak commented 3 years ago

Wich part of documentation says something about replacing? Anyway, it's hard to help without seeing any code

roburcio commented 3 years ago

Thank you for your fast reply I used this template that I found on documentation: [{% for author in results -%} {{ {id: author.id, label: author.name, value: author.name}|json_encode|raw }} {# use "value" instead of "id" key, if you use jquery-ui #} {%- if not loop.last %},{% endif -%} {%- endfor %}]

The problem is that if I replace value on the first parameter it does not work because value on second paarameter overwrite the first. Sorry for my poor english

garak commented 3 years ago

I guess that value: author.name should be removed

roburcio commented 3 years ago

Yes I did it, but it does not work. I write here my twig template Twig: [{% for elenco in risultati -%}

67

{{ {value: elenco.id, label: elenco.autore, value: elenco.autore}|json_encode|raw }} {%- if not loop.last %},{% endif -%} {%- endfor%}]

In this case when I begin to write, it shows the ids and not labels. When I choose an id it writes correctly the label in the field...

roburcio commented 3 years ago

Sorry I copied a wrong twig the line where I put values is this: {{ {value: elenco.id, label: elenco.autore}|json_encode|raw }}

Thanks!

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue is closed because was marked as stale and had no activity. Thank you for your contributions.