Skip to content

Implement describing none of the above for radio and checkbox selection questions#1799

Merged
stephencdaly merged 7 commits intomainfrom
implement-describing-none-of-the-above
Dec 16, 2025
Merged

Implement describing none of the above for radio and checkbox selection questions#1799
stephencdaly merged 7 commits intomainfrom
implement-describing-none-of-the-above

Conversation

@stephencdaly
Copy link
Contributor

What problem does this pull request solve?

Trello card: https://trello.com/c/bfFa7B13

Implement the forms-runner changes to add in a field in a conditional reveal for selection questions for the additional 'None of the above' question when one is configured.

Validation has been added that an answer is provided when the question is mandatory and 'None of the above' is selected, and that the answer is not longer than 499 characters.

This PR does not yet handle adding in the additional page for the None of the above question when an autocomplete component is shown when the selection question has more than 30 options.

This also doesn't handle displaying the answer on the 'Check your answers' page or including it in submissions.

Screenshot 2025-12-16 at 10 24 30 Screenshot 2025-12-16 at 10 24 58 Screenshot 2025-12-16 at 10 26 20

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

stephencdaly and others added 3 commits December 16, 2025 10:27
If users will be asked to provide another answer if 'None of the
above' is selected, we need to know whether an autocomplete will be
shown to determine whether the question is on the same page in a
conditional reveal or on a new page. Add this method to re-use this
code.
Add a method to the selection question model to determine if there is
an additional question that should be shown to the user when they
select 'None of the above'.

Use `Struct` rather than `OpenStruct` in the tests to better mock out
ActiveResouce::Base which throws a NoMethodError if we try to access
an attribute that doesn't exist.

Co-authored-by: Samuel Culley <samuel.culley@digital.cabinet-office.gov.uk>
If a none_of_the_above_question is defined in the answer_settings for
the question, render a field in a conditional reveal if the "None of
the above" option is selected for a radios or checkboxes selection
question. We will handle the case when an autocomplete component is
rendered when there are more than 30 options in a subsequent commit.

Co-authored-by: Samuel Culley <samuel.culley@digital.cabinet-office.gov.uk>
@stephencdaly stephencdaly marked this pull request as draft December 16, 2025 10:29
@stephencdaly stephencdaly force-pushed the implement-describing-none-of-the-above branch from 818157a to fc4cd55 Compare December 16, 2025 10:35
Add validation for the none of the above question when it is displayed
for checkboxes or radios. When an autocomplete component is displayed,
the field will be on a separate page - validation for this will be
handled in a subsequent commit.

The error messages are the same as those for a text answer, so the
Welsh translations are directly copied from those error messages.
Add a before_validation callback to clear the
`none_of_the_above_answer` for a selection question if 'None of the
above' is not the selected option. This is because we don't want to
include it in the saved answer in this case. This also means that we
no longer need to check the selected option
when applying length validation for `none_of_the_above_answer`.
@stephencdaly stephencdaly force-pushed the implement-describing-none-of-the-above branch from fc4cd55 to 303d98d Compare December 16, 2025 10:38
@stephencdaly stephencdaly marked this pull request as ready for review December 16, 2025 10:47
@stephencdaly stephencdaly changed the title Implement describing none of the above Implement describing none of the above for radio and checkbox selection questions Dec 16, 2025
Enable the describe_none_of_the_above_enabled feature flag for the
forms-admin review app.
lfdebrux
lfdebrux previously approved these changes Dec 16, 2025
Copy link
Member

@lfdebrux lfdebrux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

lfdebrux
lfdebrux previously approved these changes Dec 16, 2025
We've defined the answer_settings in the factory to use Struct rather
than OpenStruct for the answer_settings to better mock the behaviour
of ActiveResouce::Base which raises a NoMethodError when trying to
access attributes that don't exist.

Use the factory so we don't need to define this behaviour in multiple
places.
@sonarqubecloud
Copy link

@github-actions
Copy link
Contributor

🎉 A review copy of this PR has been deployed! It is made of up two components

  1. A review copy of forms-runner
  2. A production copy of forms-admin

Important

Not all of the functionality of forms-runner is present in review apps.
Functionality such as sending emails, file upload, and S3 submission types are
deliberately disabled for the sake of simplifying review apps.

You should use the full dev environment to test the functionality which is disabled here.

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

@stephencdaly stephencdaly merged commit 090b293 into main Dec 16, 2025
7 checks passed
@stephencdaly stephencdaly deleted the implement-describing-none-of-the-above branch December 16, 2025 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants