Code

Opened 5 years ago

Closed 5 years ago

#11431 closed (duplicate)

prepopulated_fields fails to update multiple fields from one source

Reported by: floledermann 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: UI/UX:

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 (0)

Change History (1)

comment:1 Changed 5 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.