Use base_form_class in InlinePanel.
See original GitHub issueCurrently, there is no possible way to specify a form for an inline.
For consistency, it should be possible to specify base_form_class
in any Model
, just like we can do it with Page
.
In my case, this is blocking since I would like to use a form field that is not a database field, then parse its data and dispatch it into multiple database fields.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:15
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Customising the editing interface — Wagtail 2.12 documentation
Wagtail automatically generates forms using the panels configured on the model. By default, this form subclasses WagtailAdminModelForm , or WagtailAdminPageForm ...
Read more >How to use InlinePanel in ModelAdmin? - Stack Overflow
Wagtail relies on the django-modelcluster library to allow the parent and child models to be handled in forms as a single unit.
Read more >Wagtail Documentation - Read the Docs
To add this to the admin interface, use the InlinePanel edit panel class: content_panels = [ ... A custom base form class can...
Read more >Wagtail 2.8 documentation
To add this to the admin interface, use the InlinePanel edit panel class: ... A custom base form class can be configured by...
Read more >Wagtail Tip #1: How to replace ParentalManyToManyField ...
In this Wagtail tip, I will talk about How to replace `ParentalManyToManyField` using Wagtail InlinePanel.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve dug into the wagtail source code and I think I found the way of how to access the form controls for the orderable (this might work for other types of inline elements/haven’t tested those).
Let’s say you have a model for a page,
with some orderable model, that is linked to the page through a related name ‘test_page_field’,
then you can access that within the clean method of the page, via
self.formsets['test_page_field'].forms
, which is a list of Django form objects, where the regular checks can be done and.add_error()
method can be used. The relevantbase_form_class
would look as follows:I hope this helps.
I think I find the solution:
1-you define your custom form for the orderable that as you know it should subclass the WagtailAdminModelForm 2-subclass the InlinePanel as it’s shown in the pic I try this works on wagtail 3
A bigger question, is there any particular reason that it is not a part of wagtail support? maybe some issues and bugs?