Skip to content

Commit ca656a6

Browse files
committed
🚧 [#5139] Replace DataContainer with FormioData instance in is_visible_in_frontend
1 parent 926a08c commit ca656a6

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/openforms/formio/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def is_visible_in_frontend(component: Component, data: DataMapping) -> bool:
334334
if not (trigger_component_key := conditional.get("when")):
335335
return not hidden
336336

337-
trigger_component_value = glom(data, trigger_component_key, default=None)
337+
trigger_component_value = data.get(trigger_component_key)
338338
compare_value = conditional.get("eq")
339339

340340
if (

src/openforms/submissions/form_logic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def evaluate_form_logic(
146146
data_diff = FormioData()
147147
for component in config_wrapper:
148148
key = component["key"]
149-
is_visible = config_wrapper.is_visible_in_frontend(key, data_container.data)
149+
is_visible = config_wrapper.is_visible_in_frontend(key, FormioData(data_container.data_without_to_python))
150150
if is_visible:
151151
continue
152152

src/openforms/submissions/tests/form_logic/test_modify_components.py

+34
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,40 @@ def test_component_visible_in_frontend(self):
874874
"Some data that must not be cleared!", submission_step.data["textField"]
875875
)
876876

877+
def test_component_visible_with_date(self):
878+
form = FormFactory.create()
879+
form_step = FormStepFactory.create(
880+
form=form,
881+
form_definition__configuration={
882+
"components": [
883+
{
884+
"key": "date",
885+
"type": "date",
886+
},
887+
{
888+
"type": "textfield",
889+
"key": "textField",
890+
"hidden": True,
891+
"conditional": {"eq": "2025-01-01", "show": True, "when": "date"},
892+
"clearOnHide": True,
893+
},
894+
]
895+
},
896+
)
897+
898+
submission = SubmissionFactory.create(form=form)
899+
submission_step = SubmissionStepFactory.create(
900+
submission=submission,
901+
form_step=form_step,
902+
data={"date": "2025-01-01", "textField": "Some data that must not be cleared!"},
903+
)
904+
905+
evaluate_form_logic(submission, submission_step, submission.data, dirty=True)
906+
907+
self.assertEqual(
908+
"Some data that must not be cleared!", submission_step.data["textField"]
909+
)
910+
877911
@tag("gh-1183")
878912
def test_component_incomplete_frontend_logic(self):
879913
form = FormFactory.create()

0 commit comments

Comments
 (0)