Skip to content

Commit

Permalink
🚧 [#4980] Trying to solve bug with nested keys not being included
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorvanwijk committed Jan 24, 2025
1 parent 57406e0 commit 2873650
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/openforms/registrations/contrib/json_dump/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from zgw_consumers.client import build_client

from openforms.formio.datastructures import FormioData
from openforms.formio.service import rewrite_formio_components
from openforms.formio.typing import (
FileComponent,
Expand Down Expand Up @@ -39,10 +40,12 @@ def register_submission(
state = submission.load_submission_value_variables_state()

# Generate values
all_values: JSONObject = {
**state.get_static_data(),
**state.get_data(), # dynamic values from user input
}
all_values = (
{
**state.get_static_data(),
**state.get_data(as_formio_data=True), # dynamic values from user input
}
)
values = {
key: value
for key, value in all_values.items()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,3 +695,27 @@ def test_radio_component_with_form_variable_as_data_source(self):
result["api_response"]["data"]["schema"]["properties"]["radio"]["enum"],
["A", "B", "C", ""],
)

def test_nested_component_key(self):
submission = SubmissionFactory.from_components(
[
{"key": "foobar", "type": "textfield", "label": "Nested key"},
],
completed=True,
submitted_data={"foobar": "baz"},
with_public_registration_reference=True,
)

json_plugin = JSONDumpRegistration("json_registration_plugin")

options: JSONDumpOptions = {
"service": self.service,
"path": "json_plugin",
"variables": ["foobar"],
}

result = json_plugin.register_submission(submission, options)
assert result is not None

print(result["api_response"]["data"])
self.assertEqual(result["api_response"]["data"]["values"]["foo.bar"], "baz")

0 comments on commit 2873650

Please sign in to comment.