Skip to content

Commit b53634b

Browse files
⏪ Revert removal of DISABLE_SENDING_HIDDEN_FIELDS feature flag
Reverts #4759. DH is facing challenges with legacy forms while upgrading to 3.0 on a strict timeline. Because the forms haven't been migrated to variables mapping yet, this has a huge impact on downstream systems processing the submissions.
1 parent 86efe1f commit b53634b

File tree

4 files changed

+121
-2
lines changed

4 files changed

+121
-2
lines changed

src/openforms/conf/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@
626626
) # 1mb in bytes
627627
# Perform HTML escaping on user's data-input
628628
ESCAPE_REGISTRATION_OUTPUT = config("ESCAPE_REGISTRATION_OUTPUT", default=False)
629+
DISABLE_SENDING_HIDDEN_FIELDS = config("DISABLE_SENDING_HIDDEN_FIELDS", default=False)
629630

630631
# TODO: convert to feature flags so that newly deployed instances get the new behaviour
631632
# while staying backwards compatible for existing instances

src/openforms/formio/rendering/default.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from dataclasses import dataclass
22
from typing import Callable, Iterator
33

4+
from django.conf import settings
45
from django.urls import reverse
56
from django.utils.html import format_html_join
67
from django.utils.safestring import SafeString, mark_safe
@@ -35,7 +36,10 @@ def is_visible(self) -> bool:
3536
# class.
3637
# In registration mode, we need to treat layout/container nodes as visible so
3738
# that their children are emitted too.
38-
if self.mode in {RenderModes.export, RenderModes.registration}:
39+
visible_modes = {RenderModes.export, RenderModes.registration}
40+
if settings.DISABLE_SENDING_HIDDEN_FIELDS:
41+
visible_modes.remove(RenderModes.registration)
42+
if self.mode in visible_modes:
3943
return True
4044

4145
# We only pass the step data, since frontend logic only has access to the current step data.

src/openforms/formio/rendering/nodes.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from dataclasses import dataclass
33
from typing import TYPE_CHECKING, Any, Callable, Iterator, Literal
44

5+
from django.conf import settings
6+
57
from glom import Path, assign, glom
68

79
from openforms.submissions.models import SubmissionStep
@@ -117,7 +119,10 @@ def is_visible(self) -> bool:
117119

118120
# everything is emitted in export mode to get consistent columns
119121
# the same happens with the registration in order to include hidden fields as well
120-
if self.mode in {RenderModes.export, RenderModes.registration}:
122+
visible_modes = {RenderModes.export, RenderModes.registration}
123+
if settings.DISABLE_SENDING_HIDDEN_FIELDS:
124+
visible_modes.remove(RenderModes.registration)
125+
if self.mode in visible_modes:
121126
return True
122127

123128
# explicitly hidden components never show up. Note that this property can be set

src/openforms/registrations/contrib/objects_api/tests/test_template.py

+109
Original file line numberDiff line numberDiff line change
@@ -438,3 +438,112 @@ def test_object_nulls_regression(self, m):
438438
},
439439
},
440440
)
441+
442+
@tag("dh-673", "gh-4140")
443+
@override_settings(DISABLE_SENDING_HIDDEN_FIELDS=True)
444+
@requests_mock.Mocker()
445+
def test_opt_out_of_sending_hidden_fields(self, m):
446+
submission = SubmissionFactory.from_components(
447+
components_list=[
448+
{
449+
"type": "radio",
450+
"key": "radio",
451+
"label": "Radio",
452+
"values": [
453+
{"label": "1", "value": "1"},
454+
{"label": "2", "value": "2"},
455+
],
456+
"defaultValue": None,
457+
"validate": {"required": True},
458+
"openForms": {"dataSrc": "manual"},
459+
},
460+
{
461+
"type": "textfield",
462+
"key": "tekstveld",
463+
"label": "Tekstveld",
464+
"hidden": True,
465+
"validate": {"required": True},
466+
"conditional": {"eq": "1", "show": True, "when": "radio"},
467+
"defaultValue": None,
468+
"clearOnHide": True,
469+
},
470+
{
471+
"type": "currency",
472+
"currency": "EUR",
473+
"key": "bedrag",
474+
"label": "Bedrag",
475+
"hidden": True,
476+
"validate": {"required": True},
477+
"conditional": {"eq": "1", "show": True, "when": "radio"},
478+
"defaultValue": None,
479+
"clearOnHide": True,
480+
},
481+
{
482+
"type": "fieldset",
483+
"key": "fieldsetNoVisibleChildren",
484+
"label": "A container without visible children",
485+
"hidden": True,
486+
"components": [
487+
{
488+
"type": "textfield",
489+
"key": "input7",
490+
"label": "Input 7",
491+
"hidden": True,
492+
}
493+
],
494+
},
495+
],
496+
with_report=True,
497+
submitted_data={"radio": "2"},
498+
form_definition_kwargs={"slug": "stepwithnulls"},
499+
)
500+
config = ObjectsAPIGroupConfigFactory.create(
501+
objecttypes_service__api_root="https://objecttypen.nl/api/v1/",
502+
)
503+
plugin = ObjectsAPIRegistration(PLUGIN_IDENTIFIER)
504+
505+
m.get(
506+
"https://objecttypen.nl/api/v1/objecttypes/f3f1b370-97ed-4730-bc7e-ebb20c230377",
507+
json={
508+
"url": "https://objecttypen.nl/api/v1/objecttypes/f3f1b370-97ed-4730-bc7e-ebb20c230377"
509+
},
510+
status_code=200,
511+
)
512+
513+
with (
514+
patch(
515+
"openforms.registrations.contrib.objects_api.plugin.get_objects_client"
516+
) as mock_objects_client,
517+
):
518+
_objects_client = mock_objects_client.return_value.__enter__.return_value
519+
_objects_client.create_object.return_value = {"dummy": "response"}
520+
521+
plugin.register_submission(
522+
submission,
523+
{
524+
"objects_api_group": config,
525+
"version": 1,
526+
"objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"),
527+
"objecttype_version": 300,
528+
# skip document uploads
529+
"informatieobjecttype_submission_report": "",
530+
"upload_submission_csv": False,
531+
"update_existing_object": False,
532+
"informatieobjecttype_attachment": "",
533+
"content_json": "{% json_summary %}",
534+
},
535+
)
536+
537+
_objects_client.create_object.mock_assert_called_once()
538+
record_data = _objects_client.create_object.call_args[1]["record_data"]["data"]
539+
# for missing values, the empty value (depending on component type) must be used
540+
# Note that the input data was validated against the hidden/visible and
541+
# clearOnHide state - absence of the data implies that the component was not
542+
# visible and its data was cleared (otherwise the value *would* have been sent
543+
# along and be present).
544+
self.assertEqual(
545+
record_data,
546+
{
547+
"stepwithnulls": {"radio": "2"},
548+
},
549+
)

0 commit comments

Comments
 (0)