Skip to content

Commit

Permalink
🚑 [DH#667] Fix editgrid recursion iter_components
Browse files Browse the repository at this point in the history
The feature added in #3977 to support edit grids only supported
direct children as editgrids (so that the children of an edit
grid itself are not yielded as standalone components), but due
to missing kwarg forwarding in the recursive calls, this did
not hold up when the editgrid itself is contained in a layout
component like a fieldset or column.
  • Loading branch information
sergei-maertens committed Apr 3, 2024
1 parent b713937 commit 0016083
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/openforms/formio/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def apply_hidden_state(
Hidden fields in Formio don't run *any* validation, see the
``Component.shouldSkipValidation`` method for reference.
"""
config_wrapper = FormioConfigurationWrapper(configuration)

# initial_data is only set if Serializer(data=...) was used, and we can't take
# (dynamic) hidden state into account without initial data.
if not hasattr(self, "initial_data"):
return

config_wrapper = FormioConfigurationWrapper(configuration)

# can't use FormioData yet because of is_visible_in_frontend
values: DataMapping = self.initial_data

Expand Down
10 changes: 8 additions & 2 deletions src/openforms/formio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def iter_components(
assert not components, "Both nested components and columns found"
for column in configuration["columns"]:
yield from iter_components(
configuration=column, recursive=recursive, _is_root=False
configuration=column,
recursive=recursive,
_is_root=False,
recurse_into_editgrid=recurse_into_editgrid,
)

for component in components:
Expand All @@ -52,7 +55,10 @@ def iter_components(
if component.get("type") == "editgrid" and not recurse_into_editgrid:
continue
yield from iter_components(
configuration=component, recursive=recursive, _is_root=False
configuration=component,
recursive=recursive,
_is_root=False,
recurse_into_editgrid=recurse_into_editgrid,
)


Expand Down

0 comments on commit 0016083

Please sign in to comment.