Support Gravity Forms 3.0 international phone field extension - #282
Support Gravity Forms 3.0 international phone field extension#282davidperezgar wants to merge 1 commit into
Conversation
The international Phone format introduced in GF 3.0 applies no format mask, so raw entry values can contain spaces, dashes, parentheses and dots around the dial code and number. Map "phone" fields through a dedicated branch in get_value_from_field() that normalizes the value to digits plus a leading "+" before it is sent to the CRM, while staying backward compatible with the classic (standard) Phone format. Closes #263 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012AdxK2JUftaVT1rt6Z3Afa
There was a problem hiding this comment.
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.
Once credits are available, push a new commit or reopen this pull request to trigger a review.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a76fe3ac33
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ); | ||
| } elseif ( $field && 'phone' === RGFormsModel::get_input_type( $field ) ) { | ||
| // Covers both the classic (standard) and GravityForms 3.0 international Phone format. | ||
| $value = apply_filters( 'formscrm_field_value_phone', rgar( $entry, $field_id ), $form['id'], $field_id, $entry ); |
There was a problem hiding this comment.
Preserve the existing generic phone-value filter
For installations that customize Gravity Forms phone fields through the existing formscrm_field_value hook, this new branch prevents that callback from running because phone fields previously fell through to the generic handler but now invoke only formscrm_field_value_phone. Those customizations will silently disappear from submitted CRM values after upgrading; retain the generic hook for phone values before applying the new phone-specific processing, or otherwise provide backward-compatible chaining.
Useful? React with 👍 / 👎.
| return array( | ||
| 'name' => $var_key, | ||
| 'value' => formscrm_normalize_phone_number( $value ), |
There was a problem hiding this comment.
Normalize phones in the dynamic-field submission path
When a feed has no explicit listFields mappings and relies on fields with adminLabel, process_feed() uses its dynamic-fields branch and appends $entry[$field->id] directly instead of calling get_value_from_field(). Consequently this new normalization branch is never reached for international phone fields in that supported path, so values such as +34 612 34 56 78 are still sent unnormalized; route phone values in the empty-$field_maps path through the same normalization.
Useful? React with 👍 / 👎.
Summary
phoneFormat: international). It's still a single scalar entry value (no new sub-inputs), but unlike the classic "standard" format it applies no mask or regex, so the raw value can arrive with spaces, dashes, parentheses and dots wrapped around the dial code and number (e.g.+34 612 34 56 78).GFCRM::get_value_from_field()had no dedicated branch forphonefields, so they fell through to the generic handler and were sent to the CRM exactly as typed — inconsistent formatting depending on how the user entered the number.phonebranch that normalizes the value to digits plus a leading+(when present) before it reaches$merge_vars, giving CRMs a consistent value regardless of format. The classic (US) Phone field goes through the same normalization now, which only strips formatting characters (parentheses/dashes) — the digits are unchanged.Changes
includes/formscrm-library/class-gravityforms.php: newphonebranch inget_value_from_field(), applying theformscrm_field_value_phonefilter and dynamic merge-tag resolution (fill_dynamic_value()) consistent with other field types, then normalizing via the new helper.includes/formscrm-library/helpers-functions.php: newformscrm_normalize_phone_number()helper — keeps a leading+and strips everything that isn't a digit.tests/Unit/test-phone-normalization.php: unit tests for the normalization helper (international format, classic/standard format, edge cases like empty values or a value with no digits).readme.txt/formscrm.php: changelog entry and version bump to 4.4.2.Closes #263.
Test plan
php -lon all changed/new files — no syntax errors.composer lint/composer phpstan/composer test— could not run in this sandbox (no network access to download Composer dev dependencies from GitHub). Please run CI on this PR to confirm.Generated by Claude Code