Fix regression in InlinePanel handling on Wagtail 6.5a0 #862
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix regression that appeared against Wagtail main following wagtail/wagtail@96f9ebe (https://github.com/wagtail/wagtail-localize/actions/runs/14027070555/job/39267538142).
TabHelper.field_edit_handler_mappingwalks the tree of panels / edit handlers to build a lookup table based on field name. However, when it encountered an InlinePanel, it followed thepanel_definitionsattribute, whose members are taken directly from the model'spanelsdefinition and contain no reference to the corresponding model.Prior to wagtail/wagtail@96f9ebe, wagtail-localize was able to call
get_form_optionson those unbound panel instances and get a result (and even a usable one, because it only cares about thewidgetitem - although it could have got that directly from the panel'swidgetattribute instead of going throughget_form_options). After this commit,get_form_optionsno longer works on unbound panel instances, because it looks at self.db_field, which is invalid without a model.Fix this by updating
TabHelper.field_edit_handler_mappingto followchild_edit_handler.childreninstead (which does correctly keep track of the model).