Opened 10 years ago

Last modified 8 years 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


(Using Django 1.2.1)

Form and Model given like so:

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

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 Phalip 10 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 10 years ago by sloggz

Component: Uncategorizeddjango.contrib.admin

comment:2 Changed 10 years ago by Julien Phalip

Has patch: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

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.

Changed 10 years ago by Julien Phalip

comment:3 Changed 10 years ago by Julien Phalip

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

comment:4 Changed 9 years ago by James Addison

Severity: Normal
Type: Bug

comment:5 Changed 9 years ago by Julien Phalip

UI/UX: set

comment:6 Changed 8 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:7 Changed 8 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:8 Changed 8 years ago by Aymeric Augustin

UI/UX: set

Revert accidental batch modification.

comment:9 Changed 8 years 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..

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