Django

Code

Ticket #11431 (closed: duplicate)

Opened 7 months ago

Last modified 7 months ago

prepopulated_fields fails to update multiple fields from one source

Reported by: floledermann Assigned to: nobody
Milestone: Component: django.contrib.admin
Version: 1.0 Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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.

Attachments

Change History

07/08/09 07:02:59 changed by ubernostrum

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to duplicate.
  • needs_tests changed.
  • needs_docs changed.

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


Add/Change #11431 (prepopulated_fields fails to update multiple fields from one source)




Change Properties
Action