-
Notifications
You must be signed in to change notification settings - Fork 92
gpps-live-refresh.php: Fixed an issue with GPPS Live Refresh with Radio Button field.
#1157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…adio Button field.
WalkthroughAdjusts form data serialization in GPPSLiveRefresh.refresh to only include checked radio inputs while continuing to serialize other inputs unchanged. The AJAX POST logic and method signatures remain the same. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
gp-preview-submission/gpps-live-refresh.php (2)
91-100: Also restrict checkboxes and skip unnamed controls to mirror real form posts.Unchecked checkboxes shouldn’t be included, and elements without a name should be ignored to avoid sending a spurious "undefined" key.
Apply this minimal diff inside the loop:
- if ( $input.is(':radio') ) { + if ( ! name ) { + return; + } + + if ( $input.is(':radio, :checkbox') ) { if ( $input.is(':checked') ) { data[name] = $input.val(); } } else { data[name] = $input.val(); }
90-101: Alternative: use serialize() for fully browser-accurate encoding (radios, checkboxes, multi-select).If you want one-liner correctness for all field types, replace the manual collection with form serialization and append the action:
var payload = self.$form.serialize() + '&action=gpps_refresh_field'; $.post( self.ajaxUrl, payload, function( response ) { /* ... */ } );This preserves duplicate keys (e.g., multi-select) and excludes disabled/unchecked controls automatically.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
gp-preview-submission/gpps-live-refresh.php(1 hunks)
🔇 Additional comments (1)
gp-preview-submission/gpps-live-refresh.php (1)
91-100: Radios: only send the checked value — good fix.This prevents unchecked radios from clobbering the group value and aligns the payload with standard form submission semantics.
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/3059656764/88676
Summary
The Live Update snippet for GPPS is not working with Radio fields, added a case for that.