From db8d6fef0a23563b91114610f8d942a0500239a1 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Thu, 12 Dec 2024 13:00:39 +0100 Subject: [PATCH] :bug: [#4884] Ensure that no form variables are created for soft required errors The soft required errors component should have the same behaviour like the content component, as it holds no submission values and is purely client-side behaviour. Formio itself excludes the content component when looping over a configuration with eachComponent, so we need to add this same logic to our own code since Formio is not aware of our custom component semantics. In the backend, we extend the behaviour for content components to the softRequiredErrors component to ensure no variables are created in the database either. --- src/openforms/forms/models/form_variable.py | 2 +- .../js/components/admin/form_design/variables/utils.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/openforms/forms/models/form_variable.py b/src/openforms/forms/models/form_variable.py index 7c94fd7297..5e7b909a8f 100644 --- a/src/openforms/forms/models/form_variable.py +++ b/src/openforms/forms/models/form_variable.py @@ -60,7 +60,7 @@ def create_for_formstep(self, form_step: "FormStep") -> list["FormVariable"]: ): if ( is_layout_component(component) - or component["type"] == "content" + or component["type"] in ("content", "softRequiredErrors") or component["key"] in existing_form_variables_keys or component_in_editgrid(form_definition_configuration, component) ): diff --git a/src/openforms/js/components/admin/form_design/variables/utils.js b/src/openforms/js/components/admin/form_design/variables/utils.js index d689b180c3..393e75cf49 100644 --- a/src/openforms/js/components/admin/form_design/variables/utils.js +++ b/src/openforms/js/components/admin/form_design/variables/utils.js @@ -60,6 +60,9 @@ const makeNewVariableFromComponent = (component, formDefinition) => { const shouldNotUpdateVariables = (newComponent, oldComponent, mutationType, stepConfiguration) => { // Issue #1695: content components are not considered layout components if (newComponent.type === 'content') return true; + // Issue #4884 - soft required errors are pretty much the same as content components, + // with additional special client-side behaviour + if (newComponent.type === 'softRequiredErrors') return true; const isLayout = FormioUtils.isLayoutComponent(newComponent); @@ -84,9 +87,10 @@ const shouldNotUpdateVariables = (newComponent, oldComponent, mutationType, step const getFormVariables = (formDefinition, configuration) => { const newFormVariables = []; - FormioUtils.eachComponent(configuration.components, component => - newFormVariables.push(makeNewVariableFromComponent(component, formDefinition)) - ); + FormioUtils.eachComponent(configuration.components, component => { + if (component.type === 'softRequiredErrors') return; + newFormVariables.push(makeNewVariableFromComponent(component, formDefinition)); + }); return newFormVariables; };