Skip to content

Fix issue with custom style getting unset on form settings update#2139

Merged
Crabcyborg merged 1 commit into
masterfrom
fix_issue_with_custom_style_getting_unset_on_form_settings_update
Nov 26, 2024
Merged

Fix issue with custom style getting unset on form settings update#2139
Crabcyborg merged 1 commit into
masterfrom
fix_issue_with_custom_style_getting_unset_on_form_settings_update

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

This input is on a page that is now getting unset.

I noticed my styles would get disabled after saving form settings after merging https://github.com/Strategy11/formidable-forms/pull/2115/files

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 26, 2024

Walkthrough

The changes in this pull request involve the addition of a new hidden input field for custom styles in the settings-advanced.php file, while simultaneously removing a similar input field from the settings-buttons.php file. The new input field is designed to store custom styling options, and its integration is done without altering the existing functionality of the form settings interface. The updates also include modifications to the logic for handling deprecated hooks in the settings-buttons.php file.

Changes

File Path Change Summary
classes/views/frm-forms/settings-advanced.php Added a hidden input field for custom styles: <input type="hidden" name="options[custom_style]" value="<?php echo esc_attr( $values['custom_style'] ); ?>" />
classes/views/frm-forms/settings-buttons.php Removed the hidden input field for custom styles and updated logic for deprecated hooks. Added a note regarding submit button settings relocation.

Possibly related PRs

  • Pro issue 5058 update form button settings #1759: This PR modifies the settings-buttons.php file by removing a hidden input field for custom styles, which is directly related to the changes made in the main PR that introduces a new hidden input field for custom styles in settings-advanced.php.
  • Remove buttons settings tab #2115: This PR also modifies the settings-buttons.php file, introducing conditional logic that affects how form styles are managed, which may relate to the overall handling of custom styles in forms as seen in the main PR.
  • Strip unexpected characters from CSS output var names #2135: This PR introduces a method to sanitize variable names in the FrmStylesHelper class, which is relevant to the handling of CSS variables and styles, potentially impacting how the new custom style input in the main PR is processed.

Suggested labels

action: needs qa


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 112e626 and b1f2a91.

📒 Files selected for processing (2)
  • classes/views/frm-forms/settings-advanced.php (1 hunks)
  • classes/views/frm-forms/settings-buttons.php (0 hunks)
💤 Files with no reviewable changes (1)
  • classes/views/frm-forms/settings-buttons.php
🔇 Additional comments (2)
classes/views/frm-forms/settings-advanced.php (2)

123-124: Implementation looks secure and well-placed.

The hidden input field is properly implemented with appropriate escaping and follows the existing pattern for options storage.


123-124: Verify custom styles migration from settings-buttons.php.

Since this field was moved from settings-buttons.php, we should ensure existing custom styles are properly migrated.

✅ Verification successful

No migration needed - custom_style field is properly handled

Based on the code analysis, the custom_style field is already properly handled in the system:

  1. The field is part of the core form options and is consistently managed across the codebase:

    • It's initialized in FrmFormsController during form creation
    • It's properly stored in form options in FrmForm model
    • It has XML import/export support in FrmXMLHelper
    • It has proper database handling for style references
  2. The move from settings-buttons.php to settings-advanced.php is just a UI change, not a data migration issue, as the underlying data structure remains the same. The field continues to use the same option name custom_style in the form options.

  3. The codebase shows mature handling of this setting, including:

    • Style ID to name conversion for exports
    • Name to ID conversion during imports
    • Fallback to default style (1) when needed
    • Proper validation and sanitization
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to custom_style in settings-buttons.php
# and verify the migration path

# Check for any remaining references to custom_style
rg -l "custom_style" classes/views/frm-forms/settings-buttons.php

# Look for any migration code or hooks that might handle the transition
rg -B 3 -A 3 "custom_style.*migration" classes/

Length of output: 115


Script:

#!/bin/bash
# Let's broaden our search to understand the migration context better

# Check git history for changes related to custom_style
git log -p --all -- "**/settings-buttons.php" "**/settings-advanced.php" | grep -A 10 -B 10 "custom_style"

# Search for any migration-related files or functions
fd migration classes/

# Look for any database upgrade scripts or migration utilities
rg -l "upgrade|migration" classes/

# Check for any references to custom_style across the codebase
rg -l "custom_style" classes/

# Look specifically at the form settings handling code
ast-grep --pattern 'function $_($$$ custom_style $$$)'

Length of output: 3642


Script:

#!/bin/bash
# Let's examine how custom_style is handled in the codebase

# Check the form model and controller for custom_style handling
rg -A 5 -B 5 "custom_style" classes/models/FrmForm.php classes/controllers/FrmFormsController.php

# Look at the settings handling in advanced settings
rg -A 5 -B 5 "custom_style" classes/views/frm-forms/settings-advanced.php

# Check for any database or settings migration code
rg -A 5 -B 5 "custom_style" classes/models/FrmMigrate.php classes/models/FrmFormMigrator.php

# Look at the XML helper for import/export handling of custom_style
rg -A 5 -B 5 "custom_style" classes/helpers/FrmXMLHelper.php

# Check styles helper for any custom style handling
rg -A 5 -B 5 "custom_style" classes/helpers/FrmStylesHelper.php

Length of output: 8277


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • 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 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.

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