Skip to content

Replace rsvp-guest-count-input and rsvp-anonymous-checkbox with configurable form-field blocks#1168

Merged
mauteri merged 13 commits intodevelopfrom
feature/GP-1091
Aug 15, 2025
Merged

Replace rsvp-guest-count-input and rsvp-anonymous-checkbox with configurable form-field blocks#1168
mauteri merged 13 commits intodevelopfrom
feature/GP-1091

Conversation

@mauteri
Copy link
Copy Markdown
Contributor

@mauteri mauteri commented Aug 12, 2025

Description of the Change

Block Template Updates

  • Updated attending.js template to use form-field with fieldName: 'gatherpress_rsvp_guest_count'
  • Updated no-status.js, waiting-list.js, and not-attending.js templates for anonymous checkbox
  • Configured form-field blocks with specific attributes (fieldType, label, placeholder, etc.)

Backend Logic Refactoring

  • Added handle_rsvp_form_fields() method to dynamically process form-field blocks based on fieldName
  • Implemented field-specific interactivity attribute injection for guest count and anonymous fields
  • Added visibility logic: hide guest count when limit is 0, hide anonymous checkbox when disabled
  • Updated meta handling to properly work with boolean values for anonymous RSVP setting

Editor Integration

  • Enhanced RSVP block editor to show/hide form fields based on event settings
  • Added applyFormFieldVisibility() function to conditionally apply CSS classes
  • Integrated guest limit and anonymous RSVP meta detection for real-time field visibility
  • Fixed meta value type consistency (boolean handling)

Code Quality Improvements

  • Fixed PHPStan static analysis issues (removed unreachable code, simplified logic flow)
  • Resolved JavaScript linting issues (spacing, trailing commas)
  • Added proper error handling and type checking
  • Improved code documentation and comments

Technical Benefits

  • Maintainability: Single form-field block handles multiple field types through configuration
  • Flexibility: Easy to add new RSVP form fields without creating new blocks
  • Consistency: Unified interactivity and visibility handling across all RSVP fields
  • Performance: Reduced block registration overhead and simplified rendering logic

Backward Compatibility

  • Existing RSVP functionality maintained
  • No breaking changes to user-facing features
  • Old block templates replaced seamlessly with new form-field configuration

Closes #1091

How to test the Change

Changelog Entry

Changed - Existing functionality

Credits

Props @mauteri

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@mauteri mauteri changed the title Started by removing instances of custom guest input field with a conf… Replace rsvp-guest-count-input and rsvp-anonymous-checkbox with configurable form-field blocks Aug 12, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Preview changes with Playground

You can preview the recent changes for PR#1168 with the following PHP versions:

PHP Version 8.3

PHP Version 7.4

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

@mauteri mauteri marked this pull request as ready for review August 15, 2025 00:37
@mauteri mauteri merged commit 2e187c1 into develop Aug 15, 2025
19 checks passed
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.

Replace Legacy RSVP Fields with New Form Input Block

1 participant