Opened 9 years ago

Closed 9 years ago

#11431 closed (duplicate)

prepopulated_fields fails to update multiple fields from one source

Reported by: Flo Ledermann Owned by: nobody
Component: contrib.admin Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When using something like this in the admin

    prepopulated_fields = {'shortname': ('title',), 'slug': ('title',), }

only one of the fields is correctly auto-populated. The reason is that contrib/admin/templates/admin/prepopulated_fields_js.html generates very simple javascript that overwrites the event listener on the source field used for updating the target field:

{% for dependency in field.dependencies %}
    document.getElementById("{{ dependency.auto_id }}").onkeyup = function() {

This should be replaced by calls to addEvent (from contrib/admin/media/js/core.js):

{% for dependency in field.dependencies %}
    addEvent(document.getElementById("{{ dependency.auto_id }}"), "keyup", function() {

I cannot create a patch right now but this should be straightforward to fix in one minute for someone with the infrastructure in place.

Change History (1)

comment:1 Changed 9 years ago by James Bennett

Resolution: duplicate
Status: newclosed

Duplicate of #7985. Please search existing tickets before filing new tickets.

Note: See TracTickets for help on using tickets.
Back to Top