Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultipleChooserPanel does not work when used in a nested InlinePanel #11233

Open
mcosti opened this issue Nov 14, 2023 · 1 comment · May be fixed by #11904
Open

MultipleChooserPanel does not work when used in a nested InlinePanel #11233

mcosti opened this issue Nov 14, 2023 · 1 comment · May be fixed by #11904
Labels
status:Unconfirmed Issue, usually a bug, that has not yet been validated as a confirmed problem. type:Bug

Comments

@mcosti
Copy link

mcosti commented Nov 14, 2023

Issue Summary

Steps to Reproduce

class AuthorPage(Page):
    author = models.ForeignKey("authors.Author", on_delete=models.PROTECT)

    content_panels = Page.content_panels + [
        FieldPanel("author"),
        InlinePanel("image_gallery_sections", label="Image gallery sections"),
    ]


class ImageGallerySection(Orderable, ClusterableModel):
    """Image gallery section, used to display multiple galleries on a page"""
    page = ParentalKey(Page, on_delete=models.CASCADE, related_name="image_gallery_sections")
    title = models.CharField(max_length=100, blank=True)

    panels = [
        FieldPanel("title"),
        MultipleChooserPanel("section_images", chooser_field_name="image")
    ]


class GallerySectionImage(Orderable):
    section = ParentalKey(ImageGallerySection, on_delete=models.CASCADE, related_name="section_images")
    image = models.ForeignKey("wagtailimages.Image", on_delete=models.CASCADE, related_name="+")

    panels = [
        FieldPanel("image"),
    ]

image
Nothing happens when clicking the "Add" button.

Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?

  • I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: no

Technical details

  • Python version: 3.11.3
  • Django version: 4.2.7
  • Wagtail version: 5.2.0
  • Browser version: Chrome 119
@mcosti mcosti added status:Unconfirmed Issue, usually a bug, that has not yet been validated as a confirmed problem. type:Bug labels Nov 14, 2023
@eyal-mor
Copy link

Got it working with a hack:

class MultipleChooserEmbededInlinePanel(InlinePanel):
    class BoundPanel(InlinePanel.BoundPanel):
        class Media:
            js = [
                # This must be defined due to an error with how Wagtail loads the chooser widget in inline panels.
                "wagtailadmin/js/chooser-widget-telepath.js",
            ]

Didn't debug to much, but this got me going 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:Unconfirmed Issue, usually a bug, that has not yet been validated as a confirmed problem. type:Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants