Auto-assign the sole visible category in StartRegistration when no category field is shown (Case 212902) - #33
Merged
janopae merged 1 commit intoAug 5, 2026
Conversation
…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
deleted the
212902-fix-registration-when-just-one-category-is-available
branch
August 5, 2026 13:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.