Opened 15 years ago
Closed 15 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 |
Description
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.
Duplicate of #7985. Please search existing tickets before filing new tickets.