---
title: "Clear a dependent selection when its parent changes"
description: "Verify that changing a country or parent category invalidates an incompatible child selection before a form can save misleading data."
canonical_url: "https://vostride.com/agent-library/forms-validation/dependent-select-reset.md"
md_url: "https://vostride.com/agent-library/forms-validation/dependent-select-reset.md"
content_kind: "recipe"
topic: "forms-validation"
---

# Clear a dependent selection when its parent changes

Verify that changing a country or parent category invalidates an incompatible child selection before a form can save misleading data.

## Risk

Dependent selects can retain the old child identifier while rendering a new label or an empty option. This recipe makes the stored parent-child relationship part of the final oracle.

## Fixtures

- A test location form offers Country A with Province A1 and Country B with Province B1.
- The application contract requires a province belonging to the currently selected country.
- A test-owned office starts with Country A and Province A1, and the fixture manifest records both identifiers.

## Steps

1. Open the office editor and verify Country A and Province A1 are initially selected.
2. Change the country to Country B and verify Province A1 is no longer a selected valid option.
3. Attempt to save before choosing a new province and verify the required-province error prevents persistence.
4. Select Province B1 and save, then verify the office detail shows Country B and Province B1.
5. Reopen the editor and verify the country and province still form the valid B pair, using an approved fixture check for stored identifiers if labels are ambiguous.

## Expected results

- The first parent change does not silently persist Country B with Province A1.
- Saving without a valid replacement child is rejected under the stated contract.
- The final stored country and province identifiers match the B relationship in the seed manifest.

## False-pass traps

- An empty-looking child dropdown can still submit an old hidden identifier.
- A success toast cannot demonstrate referential consistency between the two saved selections.

## Cleanup

- Restore the test office to its original location or delete the office fixture.

## Use with agent-qa

Adapt this test design to your application's acceptance criteria and configured target using the [recipe execution guide](/agent-library/software-factory/turn-a-recipe-into-an-agent-qa-test.md). External fixture setup and non-UI checks require your own supported hooks or test tooling. Validate the authored test, execute it, and inspect the completed evidence; this recipe is not a recorded test result.

## References

- [agent-qa test](/docs/agent-qa/configuration/test.md)
- [agent-qa first test](/docs/agent-qa/guides/first-test.md)
- [agent-qa web testing](/docs/agent-qa/guides/web-testing.md)

- [Forms and validation QA recipes](/agent-library/forms-validation.md)
- [Software factory QA library](/agent-library.md)
