Skip to content

Support Gravity Forms 3.0 international phone field extension - #282

Open
davidperezgar wants to merge 1 commit into
trunkfrom
claude/gravity-forms-intl-phone-5zzum9
Open

Support Gravity Forms 3.0 international phone field extension#282
davidperezgar wants to merge 1 commit into
trunkfrom
claude/gravity-forms-intl-phone-5zzum9

Conversation

@davidperezgar

Copy link
Copy Markdown
Contributor

Summary

  • Gravity Forms 3.0 added an international format for the Phone field (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 for phone fields, 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.
  • Adds a phone branch 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: new phone branch in get_value_from_field(), applying the formscrm_field_value_phone filter 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: new formscrm_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 -l on all changed/new files — no syntax errors.
  • Verified the normalization logic against the unit test cases with a standalone PHP script (matches expected output for all cases).
  • 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

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

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization's overage spend limit has been reached.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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 );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +1116 to +1118
return array(
'name' => $var_key,
'value' => formscrm_normalize_phone_number( $value ),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

Support Gravity Forms 3.0 international phone field extension

2 participants