Skip to content

Conversation

@saifsultanc
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/2896177464/81660

Summary

When a required field in the nested form is not filled out and the validation is displayed, the hidden field (hidden by the snippet) is also displayed.

Loom: https://www.loom.com/share/750a1f3a31be4bce8c1100adb8087922

The logic for hiding the field with the filter gform_pre_render does not seem to work post validation fail on Nested Form Modal. This is because a condition in an edge case check rgar( $_REQUEST, 'action' ) !== 'gpnf_refresh_markup' ) is true on Nested Form submission. We can add an additionally check for gform_submission_method on POST to ensure we correctly validate for hidden field scenario.

…ot working on nested modal failed validation.
@coderabbitai
Copy link

coderabbitai bot commented Apr 4, 2025

## Walkthrough
This change updates the conditional logic within the `hide_parent_entry_id_field` method in the `gp-nested-forms/gpnf-attach-child-entry-by-field.php` file. The modification broadens the condition by adding a check for the absence of the `gform_submission_method` in the POST data when the request action is neither `'gpnf_refresh_markup'` nor `'gpnf_edit_entry'`. This adjustment expands the scenarios under which the method returns the form early without further processing. No changes have been made to any exported or public entities.

## Changes

| File                                                 | Change Summary                                                                                                                                                                  |
|------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| gp-nested-forms/gpnf-attach-child-entry-by-field.php | Updated `hide_parent_entry_id_field` method: expanded conditional logic to return the form early if it is not an applicable child form or if the action is neither `'gpnf_refresh_markup'` nor `'gpnf_edit_entry'` and `gform_submission_method` is missing from POST data. |

## Sequence Diagram(s)
```mermaid
sequenceDiagram
    participant Caller as Requester
    participant Method as hide_parent_entry_id_field
    participant POST as POST Data

    Caller->>Method: Call hide_parent_entry_id_field(form, request)
    Note over Method: Check if form is an applicable child form
    alt Form is not applicable
        Method->>Caller: Return form early
    else Form is applicable
        Method->>Method: Check if action is 'gpnf_refresh_markup' or 'gpnf_edit_entry'
        alt Action is neither 'gpnf_refresh_markup' nor 'gpnf_edit_entry'
            Method->>POST: Check for 'gform_submission_method'
            alt 'gform_submission_method' is missing
                Method->>Caller: Return form early
            else 'gform_submission_method' exists
                Method->>Caller: Continue processing
            end
        else Action is 'gpnf_refresh_markup' or 'gpnf_edit_entry'
            Method->>Caller: Continue processing
        end
    end

Suggested Reviewers

  • veryspry

<!-- walkthrough_end -->

<!-- announcements_start -->

> [!TIP]
> <details>
> <summary>⚡💬 Agentic Chat (Pro Plan, General Availability)</summary>
> 
> - We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
> 
> </details>

<!-- announcements_end -->

---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between b47bd1366694ee7fdb107440dd458563f42f4ca0 and 503f11b643910ff1ecac8bed9fdf1adc0ffa248b.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `gp-nested-forms/gpnf-attach-child-entry-by-field.php` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* gp-nested-forms/gpnf-attach-child-entry-by-field.php

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIAAMibgwAMzBqXDQGWDB0+C9aMHYXMDkwBPgSHI1uWG5orgAxeAAPKMwURAcPAHd1WHsMeG5uElCMfFCO/AoAa3gMIn4sckQaemZFNF8E7Uj6CXX4Wmp4fCw0Wlp/Nul0HgpBSOZIDthKDzRIBDOySBKy2gAaBQYXC3HxRORhZ69fqDXAAgSiFhXCRIeACSKPZ4nPyBbDwfz0H45FBYxbLb4TB6oSIJULYRLZbboDA7PYHcTHb5bRAaGAIZD4BgMbAUZCIQYMeAlBjrLzyGYQj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G1FEeUG3IaHfQ3oGNLuupQmXQM522Obj0lEfiOQTTGGKLg7OdVOENxIcnPtJWgPIrD+GRBlRAspKKQkgZffwuBhTkAfpCX0FAHgkGcEWSUKAQbIHTK/NAAwKzSjRMvBARJcEPAmCgK2/8cSAOzByDo19yH6kXEWPctdDzHmkKedOl5rw8lyleNk8djirw5CMFO6DMHWQ8IwtyhC5RW3UK0SA5D2JUJdILOh2QCTqmYcQthKlQhAI5Kgcg3RSyCIPP4ER8UzwXivCuEYfAXEJH3pxferdZArhAV6fweiRi7iIIwv0olAISVQbQFc69IQKSUmyNAUi+SQBZvgU4ml7SOTIC5TmbpQx8DAuke0GjUAqIoFgx43QMqhA+B+Kiu8gRuRCZAQGAARey0CjDmEsEPJG9tgJhBIgmJQV1nDTX5FbfUHMKBkmYdRNELoenhFKIvAwUBFQkXWFGRZ0z7RzPQt9KZs8Vk1SiBs8G1CdntiuB0F4kBzwvzSagNsCQEhET7j3IwxsDAhx6RbK25obYx3tnI1gic/BoBTlPdO8hM6+xUGoXOQcC5gtNgoVg6gj60EQIeZEJB3m0HiakNZ+dC7goEFtdaAhaCrQAMxHWWotLaJASDrQSLQAQ+NtpbWOmcLaABWeakrlrsoSFtWaCrpTHXpfiiAkBJXHXlatVaAhdrssWvjf5q1RBpHmvCWgi1BUJFWqcBgx1/loFmltC1ar1VQEdsS/YZK4GlCpcE+g+ggA= -->

<!-- internal state end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=gravitywiz/snippet-library&utm_content=1067):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@github-actions
Copy link

github-actions bot commented Apr 4, 2025

Warnings
⚠️ When ready, don't forget to request reviews on this pull request from your fellow wizards.

Generated by 🚫 dangerJS against 503f11b

…ot working on nested modal failed validation.
@saifsultanc saifsultanc merged commit 2e9d14c into master May 1, 2025
3 of 4 checks passed
@saifsultanc saifsultanc deleted the saif/fix/81660-fix-snippet-parent-field branch May 1, 2025 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants