Skip to content

WAIT: Pluralize the additional age groups field identifier#1838

Open
maebeale wants to merge 4 commits into
mainfrom
maebeale/pluralize-additional-age-groups
Open

WAIT: Pluralize the additional age groups field identifier#1838
maebeale wants to merge 4 commits into
mainfrom
maebeale/pluralize-additional-age-groups

Conversation

@maebeale

Copy link
Copy Markdown
Collaborator

🤖 PR, suggested 👤 review level: 📖 Read — light-logic: a field-identifier rename with a legacy alias, no schema or data changes

What is the goal of this PR and why is this important?

The "additional age groups" form field is multi-select, so its identifier should be plural (additional_age_groups) to match what it stores and the existing additional_age_groups instance method — the singular additional_age_group read as if it held one value.

How did you approach the change?

Made additional_age_groups the canonical identifier and kept the singular as a legacy alias, mirroring the existing *_SECTOR_FIELD_IDENTIFIERS pattern: the constant is now a current-first/legacy-last array, DYNAMIC_FIELD_CATEGORY_TYPES maps both names to AgeRange, and consumers iterate the array so old form data and existing form fields keep resolving. No DB columns or migration are involved — additional age groups live in categorizable_items (is_primary: false) — so this only affects newly built forms.

Anything else to add?

Existing in-database form fields keep their singular identifier and still work via the alias; they are not auto-renamed. A backfill migration could rename them if we want the stored data to match.

Comment thread app/models/form_field.rb
ADDITIONAL_AGE_GROUP_FIELD_IDENTIFIERS = %w[additional_age_groups additional_age_group].freeze
AGE_GROUP_FIELD_IDENTIFIERS = [ PRIMARY_AGE_GROUP_FIELD_IDENTIFIER, *ADDITIONAL_AGE_GROUP_FIELD_IDENTIFIERS ].freeze

# The payment-method field. Its answer options ("Credit card (now)", etc.) are

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: Current name first, legacy singular last — same ordering convention as ADDITIONAL_SECTOR_FIELD_IDENTIFIERS. Both keys are also added to DYNAMIC_FIELD_CATEGORY_TYPES so every .key?/[id] lookup resolves either name.

sector_ids = FormField::SECTOR_FIELD_IDENTIFIERS.flat_map { |id| collect_ids_from_checkboxes(id) }
primary_age_ids = collect_ids_from_checkboxes("primary_age_group")
additional_age_ids = collect_ids_from_checkboxes("additional_age_group")
additional_age_ids = FormField::ADDITIONAL_AGE_GROUP_FIELD_IDENTIFIERS.flat_map { |id| collect_ids_from_checkboxes(id) }

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: Collects across both identifiers (flat_map) exactly like the sector line above, so registrations submitted against legacy singular fields still tag correctly.

The "additional age groups" form field is multi-select, so its identifier
should be plural to match what it stores and the existing instance method.
The legacy singular name is kept as an alias so existing form data and old
form fields keep resolving, mirroring the sector identifier pattern.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@maebeale maebeale force-pushed the maebeale/pluralize-additional-age-groups branch from 6fa850e to fdeee6e Compare June 22, 2026 06:34
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@maebeale maebeale marked this pull request as ready for review June 22, 2026 06:40
maebeale and others added 2 commits June 22, 2026 02:43
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The constant mirrors the labels each section builds and a spec asserts the
two agree, so the field-label rename has to update it too.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@maebeale maebeale changed the title Pluralize the additional age groups field identifier WAIT: Pluralize the additional age groups field identifier Jun 22, 2026
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.

1 participant