wagtail: ImageChooserField does not work in nested forms.
After this feature we are able to create nested related objects in the same form. But when we use ImageChooserField at the second level or deeper - Wagtail shows regular select instead of ImageChooserField. On the screenshot, ImageChooserField is setted for the logo field.

About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 2
- Comments: 15 (4 by maintainers)
Commits related to this issue
- Mark nested InlinePanels as experimental for now See https://github.com/wagtail/wagtail/issues/5126#issuecomment-575607574, https://github.com/wagtail/wagtail/pull/5732#issuecomment-574753410 — committed to wagtail/wagtail by gasman 4 years ago
- Convert wagtail.admin.views.pages.create and edit into class-based views Convert local variables to instance variables in CreatePageView This will allow us to break up dispatch into separate methods... — committed to lb-/wagtail by gasman 5 years ago
- Add NestedInlinePanel https://github.com/wagtail/wagtail/issues/5126 — committed to WesternFriend/westernfriend.org by brylie 3 years ago
- Add NestedInlinePanel https://github.com/wagtail/wagtail/issues/5126 — committed to WesternFriend/westernfriend.org by brylie 3 years ago
- Add NestedInlinePanel https://github.com/wagtail/wagtail/issues/5126 — committed to everinfinity/SimpleSocial by everinfinity 3 years ago
Got SnippetChooserPanel working with this:
Basically the nested-second-layer InlinePanel wasn’t providing the Page model with any widgets, while the first layer InlinePanel was doing so. Haven’t tested it with different combinations (third layer, all layers having custom panels, etc).
The suggestion above for creating a custom
InlinePanelworked in my case, as such:One thing of note is that the
titleandhelp_textdon’t work with the customNestedInlinePanel.The same issue occurs with PageChooserPanel:
+2
NestedInlinePanelignoresmax_num+1 that the
NestedInlinePanelprovided above fixes the issue for 2.14.1. Like @brylie above, it appears none of the settings carry forward; I am trying to limit the number of forms by settingmax_num, but it doesn’t appear to do anything.Copying and overriding the default
admin/templates/wagtailadmin/edit_handlers/inline_panel.js, I threw a few console.logs in there to see what was going on. Theself.formset.max_numfor theNestedInlinePanelis 1000. I’m not familiar enough with Wagtail internals to know what to do with that info, but maybe it will help someone else diagnose what’s going on.@MaziyarMK thank you for the code snippet, I used on a project running Wagtail 2.9.3 and works as expected 👌 .