Skip to content

Fix "After Payment" setting not imported for Payment actions#3021

Open
AbdiTolesa wants to merge 2 commits intomasterfrom
issue-6377
Open

Fix "After Payment" setting not imported for Payment actions#3021
AbdiTolesa wants to merge 2 commits intomasterfrom
issue-6377

Conversation

@AbdiTolesa
Copy link
Copy Markdown
Contributor

@AbdiTolesa AbdiTolesa commented Mar 13, 2026

Fix https://github.com/Strategy11/formidable-pro/issues/6377

Test steps

  1. Create a Payment form
  2. Go to the Payment Action and add "After Payment" updates mapping fields as needed for test
  3. Export the form and import it back.
  4. Go to the Payment Action and confirm that the "After Payment" field mappings are imported successfully.
image

Summary by CodeRabbit

  • Bug Fixes
    • Form duplication now correctly updates nested and array-valued field entries so duplicated forms keep proper field references.
    • Duplicate-ID mappings are applied earlier in the duplication process to ensure accurate field ID replacement for complex form configurations.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 13, 2026

📝 Walkthrough

Walkthrough

Added recursive array handling and duplicate-ID remapping in FrmFieldsHelper::switch_field_ids, and ensured FrmFormAction::duplicate_one applies switch_field_ids to array-valued post_content entries during form duplication.

Changes

Cohort / File(s) Summary
Field ID Helper Enhancement
classes/helpers/FrmFieldsHelper.php
Added handling for array values in switch_field_ids: recursively process nested arrays and apply $frm_duplicate_ids remapping before replacements.
Form Action Duplication
classes/models/FrmFormAction.php
In duplicate_one, apply FrmFieldsHelper::switch_field_ids to array-valued post_content entries so their field IDs are converted during duplication.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hop through arrays, deep and wide,
I remap IDs and turn the tide.
Nested lists now find their home,
Duplicates mapped as I roam.
Forms duplicate with nimble stride.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: addressing the 'After Payment' setting not being imported for Payment actions during duplication, which aligns with the code changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-6377
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@deepsource-io
Copy link
Copy Markdown

deepsource-io bot commented Mar 13, 2026

DeepSource Code Review

We reviewed changes in fdb3b20...ba04d25 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Mar 16, 2026 11:26a.m. Review ↗
JavaScript Mar 16, 2026 11:26a.m. Review ↗

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
classes/helpers/FrmFieldsHelper.php (1)

1828-1846: ⚠️ Potential issue | 🟡 Minor

Add numeric field ID handling to prevent skipping integer IDs in nested arrays.

The direct mapping check at lines 1842-1846 only processes string values. Integer field IDs (e.g., 123 instead of "123") skip this check entirely due to the continue at line 1833, meaning nested integer field IDs won't be converted during duplication.

While top-level numeric post_content values are handled by duplicate_one() (line 392), nested numeric IDs within arrays need conversion. This is consistent with how FrmXMLHelper and FrmFormAction handle numeric field IDs elsewhere in the codebase.

Proposed fix
 if ( ! is_string( $v ) ) {
     if ( is_array( $v ) ) {
         $val[ $k ] = self::switch_field_ids( $v );
         unset( $k, $v );
+    } elseif ( is_numeric( $v ) && isset( $frm_duplicate_ids[ $v ] ) ) {
+        $val[ $k ] = $frm_duplicate_ids[ $v ];
+        unset( $k, $v );
     }
     continue;
 }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9aa835fe-e047-4fd9-800b-f6b466b69a25

📥 Commits

Reviewing files that changed from the base of the PR and between fdb3b20 and e309133.

📒 Files selected for processing (2)
  • classes/helpers/FrmFieldsHelper.php
  • classes/models/FrmFormAction.php

@AbdiTolesa AbdiTolesa changed the title Fix After Payment setting not imported for Payment actions Fix "After Payment" setting not imported for Payment actions Mar 16, 2026
@AbdiTolesa AbdiTolesa requested a review from lauramekaj1 March 16, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant