I'm using autocomplete for a foreign key relation (using autocomplete_light.MultipleChoiceWidget).
Everything works so far, but I have an issue changing the HTML format of the selected choice.
My goal is to display the selected choice in a table row, but the widget always creates span-tags and I do not find the right point to change the formatting.
I tried to change the widget HTML template, but I could not change the markup of the single selected choice, e.g. this is what I get after selected a choice from the autocomplete widget:
<table id="id_teilnehmer-deck" class="deck div" style="">
<span class="div hilight" data-value="1"><span style="display: inline;" class="remove div">
Specifically, I would like to know how to adjust the <span class="div hilight" data-value="1"> tag.
<span class="div hilight" data-value="1">
I saw that while working on the new docs recently.
You should override Widget.addToDeck, which does choice.clone().
Also, you'll have to set bootstrap=yourbootstrap in either the python Widget, python Autocomplete, or widget html.
My bad, there's an easier option: just make your autocomplete template to present a table, with tr.choice[data-value] elements. Choices are cloned from the autocomplete into the deck when selected.
Let me know if you need add-another support in that as well - I will factor out the HTML/design parts into specific functions.
Thank you, I now use a table in the widget.html and the choice_html_format string in my AutocompleteModelBase implementation returns a table row. This is a good first step for me.
Which files would I have to change in order to extend the choice_html to display further properties of the choice?
Would there also be a possibility to change the template of the remove button, so that it appears in a table cell instead of span? Just changing span to td did not do the trick for me.
I would greatly appreciate if you could make add-another support possible!
You should use AutocompleteModelTemplate](http://django-autocomplete-light.readthedocs.org/en/docs_rewrite/template.html) instead, then you could add any further property that you want.
Did you make any progress in the script ? I'm almost done with the refactor, you might have to override at least one function (create a choice from a fresh created by add another). You'll have to make the script that overrides Widget.optionChoice.
Fix #71: Refactor HTML generation in JS
Install the dev version of django-autocomplete-light please. There is no need to do JS overrides thanks to the the refactor.
Also, try table_autocomplete example app:
Adapt to your needs and implement in your project.
Close or give feedback on this issue.
When you close this issue, django-autocomplete-light 1.1.3 will be released, including the features that you need.
Thanks for your feedback !
I just updated the hosted version by PythonAnywhere: http://jpic.pythonanywhere.com/admin/table_autocomplete/tablewidget/3/
I just tried it within my project and it works like expected.
Now I use the AutocompleteModelTemplate and based my templates on your examples.
Thanks a lot for your help!
1.1.3 released, thanks for your feedback !