Opened 14 years ago

Closed 4 years ago

#14660 closed Bug (fixed)

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: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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

Download all attachments as: .zip

Change History (11)

comment:1 by sloggz, 14 years ago

Component: Uncategorizeddjango.contrib.admin

comment:2 by Julien Phalip, 14 years ago

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.

comment:3 by Julien Phalip, 14 years ago

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

comment:4 by James Addison, 14 years ago

Severity: Normal
Type: Bug

comment:5 by Julien Phalip, 13 years ago

UI/UX: set

comment:6 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:7 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:8 by Aymeric Augustin, 13 years ago

UI/UX: set

Revert accidental batch modification.

comment:9 by anonymous, 12 years ago

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..

comment:10 by Mariusz Felisiak, 4 years ago

Has patch: unset
Patch needs improvement: unset
Resolution: fixed
Status: newclosed
UI/UX: unset

I could not reproduce this issue in Django 1.8+, I haven't checked with older versions.

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