Skip to content

Commit

Permalink
Fix chooser blocks in StructBlock not overrideable
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolab committed Nov 1, 2021
1 parent e782c78 commit 534f4b8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions wagtail_localize/views/edit_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def widget_from_field(field):

return {"type": "unknown"}

def widget_from_block(block):
def widget_from_block(block, block_field_name=None):
if isinstance(block, blocks.PageChooserBlock):
return {
"type": "page_chooser",
Expand Down Expand Up @@ -359,6 +359,8 @@ def widget_from_block(block):
return {
"type": "text",
}
elif isinstance(block, blocks.StructBlock):
return widget_from_block(block.child_blocks.get(block_field_name))

return {"type": "unknown"}

Expand All @@ -371,6 +373,7 @@ def widget_from_block(block):
block_field = block_type.child_blocks[block_field_name].label
else:
block_field = None
block_field_name = None

return {
"tab": tab,
Expand All @@ -379,7 +382,9 @@ def widget_from_block(block):
"blockId": content_path_components[1],
"fieldHelpText": "",
"subField": block_field,
"widget": widget_from_block(block_type) if widget else None,
"widget": widget_from_block(block_type, block_field_name)
if widget
else None,
}

elif (
Expand Down

0 comments on commit 534f4b8

Please sign in to comment.