Code

Opened 3 years ago

Last modified 18 months ago

#14660 new Bug

Using a CheckboxSelectMultiple widget on a M to M field in Admin causes 'SelectBox is not defined' JS error in RelatedObjectLookups.js

Reported by: sloggz Owned by: nobody
Component: contrib.admin Version: 1.2
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: yes

Description

(Using Django 1.2.1)

Form and Model given like so:

forms.py:

class PictureGalleryForm(ModelForm):    
    class Meta:
        model=PictureGallery
        widgets = {
            'pictures' : CheckboxSelectMultiple,
        
        }


models.py:

class GalleryCommon(models.Model):
    date_created = models.DateTimeField(auto_now_add=True)
    date_updated = models.DateTimeField(auto_now=True)
    title = models.CharField(max_length=256)
    
    class Meta:
        abstract = True

class PictureGallery(GalleryCommon):
    pictures = models.ManyToManyField(Picture, related_name="pic_gallery", help_text="Select Gallery Images.")
    
    def __unicode__(self):
        return (self.title)

To encounter the error, register PictureGallery with admin using the PictureGalleryForm and click the green plus arrow to add a picture.
On clicking the save button in the popup admin window, the picture will save, but the popup will hang at line 92 of RelatedObjectLookup.js .

The error is 'SelectBox is not defined.'

Assume this occurs because somehow the 'if' statement at line 76 goes wrong.

As best I can tell this is similar to tickets #7133, #5731, and #10191 but not the same.

Attachments (1)

14660_CheckboxSelectMultiple_js_support.diff (1.6 KB) - added by julien 3 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 3 years ago by sloggz

  • Component changed from Uncategorized to django.contrib.admin
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 3 years ago by julien

  • Has patch set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

Currently Django's Javascript doesn't seem to support the use of CheckboxSelectMultiple. Accepting this ticket on the principle that it's a shame and that it should. Attaching a patch that provides the wanted functionality, though it could probably be improved a little bit.

comment:3 Changed 3 years ago by julien

This is probably related to #10191 (which also has a patch).

comment:4 Changed 3 years ago by jaddison

  • Severity set to Normal
  • Type set to Bug

comment:5 Changed 3 years ago by julien

  • UI/UX set

comment:6 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:7 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:8 Changed 2 years ago by aaugustin

  • UI/UX set

Revert accidental batch modification.

comment:9 Changed 18 months ago by anonymous

If there was no choices (no checkboxes available in the page) the add another doesn't work. since the JS assumes that at least there is one choice present to append the new entry after it..

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


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

 
Note: See TracTickets for help on using tickets.