Skip to content

Commit

Permalink
Merge pull request #3934 from open-formulieren/feature/3890-allow-hid…
Browse files Browse the repository at this point in the history
…den-fields-to-be-sent-to-registration-systems

[#3890] Allow hidden fields to be sent to registration systems
  • Loading branch information
sergei-maertens authored Feb 28, 2024
2 parents aa529ed + 6668d73 commit 6d9428a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/openforms/formio/rendering/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def is_visible(self) -> bool:
from .default import EditGridGroupNode

# everything is emitted in export mode to get consistent columns
if self.mode == RenderModes.export:
# the same happens with the registration in order to include hidden fields as well
if self.mode in {RenderModes.export, RenderModes.registration}:
return True

# explicitly hidden components never show up. Note that this property can be set
Expand Down
40 changes: 40 additions & 0 deletions src/openforms/formio/rendering/tests/test_component_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,46 @@ def test_explicitly_hidden_component_skipped(self):
self.assertEqual(len(nodelist), 1)
self.assertEqual(nodelist[0].label, "A container without visible children")

def test_explicitly_hidden_component_not_skipped_when_registration(self):
# we always need a renderer instance
renderer = Renderer(
self.submission, mode=RenderModes.registration, as_html=False
)

with self.subTest("Simple hidden leaf component"):
component = self.step.form_step.form_definition.configuration["components"][
1
]
assert component["key"] == "input2"
assert component["hidden"]

component_node = ComponentNode.build_node(
step_data=self.step.data, component=component, renderer=renderer
)

nodelist = list(component_node)

self.assertEqual(len(nodelist), 1)

with self.subTest("Nested hidden component"):
fieldset = self.step.form_step.form_definition.configuration["components"][
7
]
assert not fieldset["hidden"]

# set up mock registry and component class for test
register = Registry()

with patch("openforms.formio.rendering.registry.register", new=register):
component_node = ComponentNode.build_node(
step_data=self.step.data, component=fieldset, renderer=renderer
)

nodelist = list(component_node)

self.assertEqual(len(nodelist), 2)
self.assertEqual(nodelist[0].label, "A container without visible children")

def test_export_always_emits_all_nodes(self):
renderer = Renderer(self.submission, mode=RenderModes.export, as_html=False)

Expand Down

0 comments on commit 6d9428a

Please sign in to comment.