Skip to content

Commit

Permalink
🐛 [#4884] Ensure that no form variables are created for soft required…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
sergei-maertens committed Dec 12, 2024
1 parent 0dd2174 commit db8d6fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/openforms/forms/models/form_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
):
Expand Down
10 changes: 7 additions & 3 deletions src/openforms/js/components/admin/form_design/variables/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
};

Expand Down

0 comments on commit db8d6fe

Please sign in to comment.