REST API: Differentiate between checkbox and toggles#1575
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## development #1575 +/- ##
===============================================
- Coverage 77.82% 77.79% -0.04%
===============================================
Files 255 255
Lines 13899 13906 +7
Branches 370 370
===============================================
+ Hits 10817 10818 +1
- Misses 3074 3080 +6
Partials 8 8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f8329d7 to
76afb40
Compare
|
Coverage report for commit: cb384d4 Summary - Lines: 92.96% | Methods: 88.24% | Branches: 81.37%
🤖 Jest coverage report |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Coverage report for commit: cb384d4 Summary - Lines: 82.30% | Methods: 88.67%
🤖 PHPUnit coverage report |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Toggle settings serialise to 'Yes'/'No' while checkbox settings serialise to '1'/'' to match how each field type is stored. Rename the unreleased schema format string 'yes_no' -> 'yes-no' for consistency with the existing 'hex-color' format, and add a dedicated 'checkbox' format with its own prepare/response handling. Adds PHPUnit coverage for both formats. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
76afb40 to
cb384d4
Compare
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.
Description
The Form Settings REST endpoint treated all boolean settings the same way, but the two underlying field types serialise differently in storage: toggle settings are stored as
'Yes'/'No', whereas checkbox settings are stored as'1'/''. Mapping both to the same boolean format meant checkbox settings round-tripped incorrectly.This differentiates the two:
checkboxschema format with its own prepare handling — atrue/falseboolean serialises to'1'/''.'Yes'/'No'serialisation.yes_no→yes-nofor consistency with the existinghex-colorformat.Changes:
src/Rest/Rest_Form_Settings.php— split thecheckboxandtogglecases when building the schema (checkbox →format: 'checkbox', toggle →format: 'yes-no'), and add a prepare branch converting a checkbox boolean to'1'/''.src/Helper/Helper_Options_Fields.php— update the two hard-codedyes_noformat strings toyes-no.tests/phpunit/integration/Rest/Test_Rest_Form_Settings.php— PHPUnit coverage for both theyes-no(toggle) andcheckboxformats.Testing instructions
GET/gravity-pdf/v1/form/{form_id}/{pdf_id}and confirm checkbox-backed settings exposeformat: "checkbox"in the schema while toggle-backed settings exposeformat: "yes-no".POST/PATCHa checkbox setting astrueand confirm it is stored as'1'(andfalse→'').POST/PATCHa toggle setting astrueand confirm it is stored as'Yes'(andfalse→'No').Or run the PHPUnit coverage:
Screenshots
Checklist:
Additional Comments