Skip to content

Auto-assign the sole visible category in StartRegistration when no category field is shown (Case 212902) - #33

Merged
janopae merged 1 commit into
masterfrom
212902-fix-registration-when-just-one-category-is-available
Aug 5, 2026
Merged

Auto-assign the sole visible category in StartRegistration when no category field is shown (Case 212902)#33
janopae merged 1 commit into
masterfrom
212902-fix-registration-when-just-one-category-is-available

Conversation

@janopae

@janopae janopae commented Aug 5, 2026

Copy link
Copy Markdown
Member

When only one newsletter category existed, TypeHasCategoriesElementTrait skipped adding the categories field to the form. As a result, the model transformer created a PendingOptIn with no categories, and the confirmed Recipient ended up stored with no subscriptions.

StartRegistration\Type now detects this case inside the model transformer's reverseTransform and injects the single visible category into the form data before passing it to the PendingOptInFactory.

As part of this, addCategoriesElementToForm() was refactored: the trait no longer calls findVisible() itself or owns the categoryRepository property. Instead, it receives the pre-fetched choices as a parameter and unconditionally adds the field. The decision of whether to call addCategoriesElementToForm() at all now rests with the calling types (StartRegistration\Type and EditRegistration\Type), which avoids a second findVisible() call and separates the concerns of fetching categories and rendering the form field.

…tegory field is shown

When only one newsletter category existed, TypeHasCategoriesElementTrait skipped
adding the categories field to the form. As a result, the model transformer created
a PendingOptIn with no categories, and the confirmed Recipient ended up stored with
no subscriptions.

StartRegistration\Type now detects this case inside the model transformer's
reverseTransform and injects the single visible category into the form data before
passing it to the PendingOptInFactory.

As part of this, addCategoriesElementToForm() was refactored: the trait no longer
calls findVisible() itself or owns the categoryRepository property. Instead, it
receives the pre-fetched choices as a parameter and unconditionally adds the field.
The decision of whether to call addCategoriesElementToForm() at all now rests with
the calling types (StartRegistration\Type and EditRegistration\Type), which avoids
a second findVisible() call and separates the concerns of fetching categories and
rendering the form field.
@janopae janopae changed the title Auto-assign the sole visible category in StartRegistration when no category field is shown Auto-assign the sole visible category in StartRegistration when no category field is shown (Case 212902) Aug 5, 2026
@janopae
janopae merged commit a92cf11 into master Aug 5, 2026
4 of 6 checks passed
@janopae
janopae deleted the 212902-fix-registration-when-just-one-category-is-available branch August 5, 2026 13:15
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