2

I'm using django-autocomplete-light with django 1.8. I want to be able to copy the selected contents from one autocomplete field into another which requires overriding javascript code.

I tried duplicating the html content inside the autocomplete tool into another one in the browser debugger which looked good but when I click the save button in the admin page, it ignores my copied value. Any ideas?

max
  • 9,708
  • 15
  • 89
  • 144
  • 1
    Perhaps the form fields have the same name ? – jpic Oct 19 '16 at 09:33
  • That's a good point. I tried again making sure the field names are incremented and this time it worked; the main problem is that there are 2 spans. The second one is identical to the first except that it is hidden but when you click on it, you set the focus which makes the second span visible which I though is redundant and deleted it...long story short, I need to copy both spans and make the second one hidden. – max Oct 19 '16 at 22:55
  • That really looks like a github issue that was investigated not so long ago, https://github.com/yourlabs/django-autocomplete-light/issues/757 I tried a crystal ball answer :D – jpic Oct 20 '16 at 10:51

1 Answers1

0

It works if you use an empty form for #form_template as such:

<div class = 'table' id="form_template" style="display:none">
    {{ formset.empty_form }}
</div>
<div class = 'table'>
                <table>
<!-- don't use #form_template in your actual form -->

From github issue

jpic
  • 32,891
  • 5
  • 112
  • 113