diff --git a/docs/installation/config.rst b/docs/installation/config.rst index f6907898b8..266d2fb026 100644 --- a/docs/installation/config.rst +++ b/docs/installation/config.rst @@ -364,7 +364,7 @@ Other settings .. _django-sendfile documentation: https://django-sendfile2.readthedocs.io/en/stable/backends.html -.. _`Django DATABASE settings`: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-DATABASE-ENGINE +.. _`Django DATABASE settings`: https://docs.djangoproject.com/en/4.2/ref/settings/#engine .. _installation_environment_config_feature_flags: diff --git a/docs/manual/forms/soft_required_fields.rst b/docs/manual/forms/soft_required_fields.rst index 9b55904fa2..995e53e6f9 100644 --- a/docs/manual/forms/soft_required_fields.rst +++ b/docs/manual/forms/soft_required_fields.rst @@ -18,7 +18,7 @@ ze niet om het formulier in te zenden. Formulierconfiguratie ===================== -.. note:: deze documentatie gaat ervan uit dat je bekend met de basis van +.. note:: Deze documentatie gaat ervan uit dat je bekend met de basis van :ref:`formulieren beheren `. Het is belangrijk dat je in de betreffende formulierstap(pen) een component toevoegt diff --git a/src/openforms/formio/rendering/default.py b/src/openforms/formio/rendering/default.py index 8118b7811a..6808a1d334 100644 --- a/src/openforms/formio/rendering/default.py +++ b/src/openforms/formio/rendering/default.py @@ -336,3 +336,17 @@ def label(self) -> str: def render(self) -> str: return f"{self.indent}{self.label}" + + +@register("softRequiredErrors") +class SoftRequiredErrors(ComponentNode): + + @property + def is_visible(self) -> bool: + """ + Mark soft required errors nodes as never visible. + + They are rendered client-side only, so should not show in summaries, PDF, + registration data... + """ + return False diff --git a/src/openforms/formio/rendering/tests/test_component_node.py b/src/openforms/formio/rendering/tests/test_component_node.py index 05051c2595..0cb7f4c9c4 100644 --- a/src/openforms/formio/rendering/tests/test_component_node.py +++ b/src/openforms/formio/rendering/tests/test_component_node.py @@ -11,7 +11,7 @@ from ..structured import render_json -class FormNodeTests(TestCase): +class ComponentNodeTests(TestCase): @classmethod def setUpTestData(cls): super().setUpTestData() @@ -203,6 +203,13 @@ def setUpTestData(cls): }, }, # TODO columns + # soft required validation errors -> always ignored + { + "key": "softRequiredErrors", + "type": "softRequiredErrors", + "html": "

I am hidden

", + "label": "Soft required errors", + }, ] } data = { @@ -451,7 +458,7 @@ def test_render_mode_pdf(self): ) nodelist += list(component_node) - self.assertEqual(len(nodelist), 10) + self.assertEqual(len(nodelist), 11) labels = [node.label for node in nodelist] expected_labels = [ "Input 1", @@ -464,6 +471,7 @@ def test_render_mode_pdf(self): "Input 11", "Visible editgrid with hidden children", "Input 14", + "Soft required errors", # not actually rendered in full render mode ] self.assertEqual(labels, expected_labels) @@ -497,6 +505,7 @@ def test_render_mode_summary(self): "Input 11", "Visible editgrid with hidden children", "Input 14", + "Soft required errors", # not actually rendered in full render mode ] self.assertEqual(labels, expected_labels) diff --git a/src/openforms/formio/tests/test_variables_injection.py b/src/openforms/formio/tests/test_variables_injection.py index db15b8542d..724e0750a1 100644 --- a/src/openforms/formio/tests/test_variables_injection.py +++ b/src/openforms/formio/tests/test_variables_injection.py @@ -184,3 +184,21 @@ def test_rendering_nested_structures(self): result, {"topLevel": {"nested": "yepp"}}, ) + + def test_soft_required_errors_no_server_side_template_evaluation(self): + configuration = { + "components": [ + { + "key": "softRequiredErrors", + "type": "softRequiredErrors", + "html": "

I am hidden

{{ missingFields }}{% now %}", + }, + ] + } + + inject_variables(FormioConfigurationWrapper(configuration), {}) + + self.assertEqual( + configuration["components"][0]["html"], + "

I am hidden

{{ missingFields }}{% now %}", + ) diff --git a/src/openforms/formio/variables.py b/src/openforms/formio/variables.py index 61da96ab2e..b8d1476944 100644 --- a/src/openforms/formio/variables.py +++ b/src/openforms/formio/variables.py @@ -37,6 +37,10 @@ def iter_template_properties(component: Component) -> Iterator[tuple[str, JSONVa Each item returns a tuple with the key and value of the formio component. """ + # no server-side template evaluation here + if component["type"] == "softRequiredErrors": + return + for property_name in SUPPORTED_TEMPLATE_PROPERTIES: property_value = component.get(property_name) yield (property_name, property_value) diff --git a/src/openforms/js/lang/formio/en.json b/src/openforms/js/lang/formio/en.json index b32c87960e..2805e38d5a 100644 --- a/src/openforms/js/lang/formio/en.json +++ b/src/openforms/js/lang/formio/en.json @@ -40,5 +40,6 @@ "{{ labels }} or {{ lastLabel }}": "{{ labels }} or {{ lastLabel }}", "invalid_time": "Only times between {{ minTime }} and {{ maxTime }} are allowed.", "You must select at least {{minCount}} items.": "Ensure this field has at least {{minCount}} checked options.", + "Empty fields": "Fields without a value", "": "" } diff --git a/src/openforms/js/lang/formio/nl.json b/src/openforms/js/lang/formio/nl.json index 0c9bfb4dd9..a6c048617e 100644 --- a/src/openforms/js/lang/formio/nl.json +++ b/src/openforms/js/lang/formio/nl.json @@ -408,5 +408,6 @@ "You must verify this email address to continue.": "Om door te gaan moet je dit e-mailadres bevestigen.", "You must select at least {{minCount}} items.": "Zorg dat dit veld {{minCount}} of meer opties aangevinkt heeft.", "Soft required errors": "Foutmeldingen aangeraden velden", + "Empty fields": "Velden zonder antwoord", "": "" } diff --git a/src/openforms/submissions/tests/test_submission_report.py b/src/openforms/submissions/tests/test_submission_report.py index dc145a2e00..2a80608246 100644 --- a/src/openforms/submissions/tests/test_submission_report.py +++ b/src/openforms/submissions/tests/test_submission_report.py @@ -424,6 +424,8 @@ def test_report_is_generated_in_same_language_as_submission(self): plugins = set(ct for ct, _ in register.items()) # WYSIWIG seems untranslated in SDK TODO after/in issue #2475 plugins.remove("content") + # soft-required errors are not shown in PDF report + plugins.remove("softRequiredErrors") tested_plugins = set(ct for ct, _ in fields if ct in plugins) # add checked structural "layout" components that don't require