Skip to content

HOLD: Extract BaseRegistrationFormBuilder to share fields across form types#1301

Open
maebeale wants to merge 2 commits intomainfrom
maebeale/shared-form-builder
Open

HOLD: Extract BaseRegistrationFormBuilder to share fields across form types#1301
maebeale wants to merge 2 commits intomainfrom
maebeale/shared-form-builder

Conversation

@maebeale
Copy link
Collaborator

@maebeale maebeale commented Mar 2, 2026

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

  • Three form builder services (Short, Extended, Scholarship) duplicated identical helper methods, scholarship fields, and contact fields
  • Changing a shared field (e.g., adding email confirmation) required updating multiple files independently, risking drift
  • Several field key mismatches between builders caused silent bugs in validation and tag assignment

How did you approach the change?

  • Extracted BaseRegistrationFormBuilder with shared helpers (add_header, add_field) and reusable field sections (build_basic_contact_fields, build_scholarship_fields, build_consent_fields)
  • All three builders now inherit from the base class, eliminating ~210 lines of duplication
  • Fixed three bugs discovered during the refactor:
    • Email confirmation key mismatch: Extended form used primary_email_confirmation but controller validation checked confirm_email — confirmation match validation was silently skipped for extended forms
    • workshop_settings vs workshop_environments: Builder created workshop_settings but the service and helper looked for workshop_environments — professional tags were never assigned
    • Redundant confirm email storage: save_form_fields skipped primary_email_confirmation but not confirm_email — short form stored confirmation email unnecessarily
  • Updated email row logic in new.html.erb to support 3-column layout (email | confirm | type) when all three fields exist
  • Added specs for Short and Extended form builders

UI Testing Checklist

  • Short form registration renders correctly with contact, consent, qualitative, and scholarship sections
  • Extended form registration renders correctly with all sections
  • Email confirmation validation works on both form types
  • Email row displays as 3-column on extended form (email | confirm email | email type)
  • Email row displays as 2-column on short form (email | confirm email)
  • Registration show page displays correctly, skipping confirm email field
  • Scholarship application form still builds correctly

Anything else to add?

  • This is forward-only: existing forms in the database are untouched. Only newly built forms will use the shared definitions.
  • The base class is designed for future extensibility — an AuthenticatedEventRegistrationFormBuilder can inherit the same shared sections and add its own fields.

🤖 Generated with Claude Code

maebeale and others added 2 commits March 1, 2026 14:49
…ion forms

- Add confirm email field with server-side match validation
- Group email, confirm email, and email type in one row
- Label as "Email" on short forms, "Primary Email" when secondary exists
- Add address type (Home/Work) on same row as street address
- Add consent and training interest questions (appear on all forms)
- Skip storing confirmation field value in user form submissions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Short, Extended, and Scholarship form builders now inherit from a common
base class that provides shared helpers (add_header, add_field) and
reusable field sections (basic contact, scholarship, consent). This
eliminates duplication and ensures changes to shared fields propagate
to all form types.

Also fixes three bugs:
- Email confirmation key mismatch (primary_email_confirmation → confirm_email)
  so validation now works for extended forms
- workshop_settings → workshop_environments so professional tags get assigned
- confirm_email responses no longer stored redundantly in PersonForm

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@maebeale maebeale changed the title Extract BaseRegistrationFormBuilder to share fields across form types HOLD: Extract BaseRegistrationFormBuilder to share fields across form types Mar 2, 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