Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved fields dependence (show/hide) in backend's config section #2150

Merged
merged 6 commits into from
Mar 2, 2024

Conversation

luigifab
Copy link
Contributor

@luigifab luigifab commented May 25, 2022

Description

This fix display of customized elements when a field depend on another one.

Manual testing scenarios

First, update app/code/core/Mage/Page/etc/system.xml like this:

diff --git a/app/code/core/Mage/Page/etc/system.xml b/app/code/core/Mage/Page/etc/system.xml
index 635353f637..88c1aba8c7 100644
--- a/app/code/core/Mage/Page/etc/system.xml
+++ b/app/code/core/Mage/Page/etc/system.xml
@@ -37,6 +37,15 @@
                     <show_in_website>1</show_in_website>
                     <show_in_store>1</show_in_store>
                     <fields>
+                        <yesno>
+                            <label>yesno</label>
+                            <frontend_type>select</frontend_type>
+                            <source_model>adminhtml/system_config_source_yesno</source_model>
+                            <sort_order>4</sort_order>
+                            <show_in_default>1</show_in_default>
+                            <show_in_website>1</show_in_website>
+                            <show_in_store>1</show_in_store>
+                        </yesno>
                         <shortcut_icon translate="label comment">
                             <label>Favicon Icon</label>
                             <comment>Allowed file types: ICO, PNG, GIF, JPG, JPEG, APNG. Not all browsers support all these formats!</comment>
@@ -47,6 +56,7 @@
                             <show_in_default>1</show_in_default>
                             <show_in_website>1</show_in_website>
                             <show_in_store>1</show_in_store>
+                            <depends><yesno>1</yesno></depends>
                         </shortcut_icon>
                         <default_title translate="label">
                             <label>Default Title</label>

Go to System / Configuration / Design / HTML head:

image

Here, there are no problems with the favicon, when the select is yes or no.

But... if you customize the element and add some html tags, like for example by adding in app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Image.php:

    public function getElementHtml() {
        return '<div style="background-color:yellow;">'.parent::getElementHtml().'</div>';
    }

No:
image
Yes:
image

Apply the PR, then try again No:
image

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
  • Add yourself to contributors list

@github-actions github-actions bot added Component: Sales Relates to Mage_Sales JavaScript Relates to js/* labels May 25, 2022
js/mage/adminhtml/form.js Outdated Show resolved Hide resolved
fballiano
fballiano previously approved these changes Feb 21, 2024
Copy link
Contributor

@fballiano fballiano left a comment

Choose a reason for hiding this comment

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

tested and I couldn't find anything not working

js/mage/adminhtml/form.js Outdated Show resolved Hide resolved
Removed extra semicolon
Copy link
Contributor

@kiatng kiatng left a comment

Choose a reason for hiding this comment

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

Tested. I removed an extra semicolon.

@fballiano fballiano changed the title Allow to hide or show customized config elements Improved fields dependence (show/hide) in backend's config section Mar 2, 2024
@fballiano fballiano merged commit ac50a6a into OpenMage:main Mar 2, 2024
17 checks passed
@luigifab luigifab deleted the hide-show branch March 11, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Sales Relates to Mage_Sales JavaScript Relates to js/*
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants