Skip to content

Fix option validation where separate values has been turned off#2383

Merged
Crabcyborg merged 1 commit into
masterfrom
fix_option_validation_where_separate_values_have_since_been_turned_off
Jun 5, 2025
Merged

Fix option validation where separate values has been turned off#2383
Crabcyborg merged 1 commit into
masterfrom
fix_option_validation_where_separate_values_have_since_been_turned_off

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Jun 5, 2025

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2025

Walkthrough

The validation logic for choice field options in FrmEntryValidate.php was updated to use either the option's 'value' or 'label' for comparison, based on the field's "separate_value" setting. This adjustment affects both individual option validation and dynamic option mapping, while the rest of the validation process remains unchanged.

Changes

File(s) Change Summary
classes/models/FrmEntryValidate.php Updated option validation logic to use 'value' or 'label' for comparisons based on "separate_value".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FrmEntryValidate
    participant Field

    User->>FrmEntryValidate: Submit choice field value(s)
    FrmEntryValidate->>Field: Check "separate_value" setting
    FrmEntryValidate->>FrmEntryValidate: For each option, use 'value' or 'label' based on setting
    FrmEntryValidate-->>User: Return validation result
Loading

Possibly related PRs

  • Improve option is valid check when shortcodes are used #2368: Both PRs modify the validation logic in the option_is_valid and options_are_dynamic_based_on_hook methods of FrmEntryValidate.php to change how option values are processed before comparison, indicating a direct relation in the code areas they affect.
  • Add trim check when checking for valid option match #2372: Both PRs modify the option_is_valid method in FrmEntryValidate.php to refine how option values are validated, with the main PR adjusting the key used for comparison based on the "separate_value" setting and the retrieved PR adding a trimmed value equality check.

Suggested labels

run analysis, run tests


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d5af72e and ea81661.

📒 Files selected for processing (1)
  • classes/models/FrmEntryValidate.php (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: Run PHP Syntax inspection (8.3)
  • GitHub Check: Cypress
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: Cypress
🔇 Additional comments (2)
classes/models/FrmEntryValidate.php (2)

250-255: LGTM! Correct fix for separate_value validation logic.

The implementation properly checks the field's separate_value option to determine whether to use the option's 'value' or 'label' for validation. This fixes the bug where validation would incorrectly use the wrong part of the option data when separate values is disabled.


297-306: LGTM! Consistent implementation for dynamic options.

The callback function correctly mirrors the same separate_value logic implemented in the option_is_valid method, ensuring consistent behavior across both static and dynamic option validation scenarios.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2025

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 27.55%. Comparing base (72bd7d1) to head (ea81661).
Report is 20 commits behind head on master.

Files with missing lines Patch % Lines
classes/models/FrmEntryValidate.php 0.00% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2383      +/-   ##
============================================
- Coverage     27.62%   27.55%   -0.08%     
- Complexity     8663     8672       +9     
============================================
  Files           140      140              
  Lines         28596    28626      +30     
============================================
- Hits           7901     7889      -12     
- Misses        20695    20737      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Crabcyborg Crabcyborg merged commit 40da397 into master Jun 5, 2025
32 of 36 checks passed
@Crabcyborg Crabcyborg deleted the fix_option_validation_where_separate_values_have_since_been_turned_off branch June 5, 2025 17:12
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