Skip to content

Commit

Permalink
♿ [#5047] Show "not filled in" when a field is empty in the submissio…
Browse files Browse the repository at this point in the history
…n report pdf

To indicate when a field has been left empty by the user, show "No information provided" in the place where the filled in information would have been.
This also helps screen reader users identify which fields aren't filled in.
  • Loading branch information
robinmolen committed Feb 24, 2025
1 parent eaf228c commit ea4b733
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/openforms/formio/formatters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ def __call__(self, component: ComponentT, value: Any) -> str:
# note all this depends on value not being unexpected type or shape
values = self.normalise_value_to_list(component, value)

formatted_values = (
formatted_values = list(
force_str(self.format(component, value)) for value in values
)

# Check if formatted_values isn't empty
if len(formatted_values) == 0:
return self.process_result(component, "")

# logically we'd want a .filter_formatted_values() step here
return self.process_result(
component, self.join_formatted_values(component, formatted_values)
Expand Down
2 changes: 2 additions & 0 deletions src/openforms/formio/formatters/formio.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def format(self, component: SelectBoxesComponent, value: dict[str, bool]) -> str
# For the html output, wrap the values in li tags and put it inside an ul tag.
# The selectboxes formatter handles all values at the same time,
# so handle the full html formatting here.
if not selected_labels:
return ""
return format_html(
"<ul>{values}</ul>",
values=format_html_join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ <h2 class="subtitle">{{ submission_step_node.render }}</h2>
</span>

<div aria-labelledby="{{ node_path }}" class="submission-step-row__value{% if not component_node.display_value %} submission-step-row__value--empty{% endif %}">
{{ component_node.display_value|default:"" }}
{% if component_node.display_value %}
{{ component_node.display_value }}
{% elif not component_node.layout_modifier %}
{% trans "No information provided" %}
{% endif %}
</div>
{% endwith %}
{% endif %}
Expand Down

0 comments on commit ea4b733

Please sign in to comment.