Skip to content

Configuration fields not disabled when setting options in config.php #23014

Open
@dverkade

Description

@dverkade

Preconditions

  1. Magento 2.3.1

Steps to reproduce

  1. In the config.php file overwrite a config setting of a fields which is dependent on another field. So the field you're trying to set the configuration variable on is only visible when another field is enabled.
  2. Go into the Magento backend and verify that the field is set and can no longer be changed by the user.

system.xml file

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="tax">
            <group id="avatax" translate="label" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>AvaTax Settings</label>
                <comment><![CDATA[For complete and up-to-date documentation, please visit <a href="http://www.classyllama.com/documentation/extensions/avatax-magento-2-module" target="_blank">www.classyllama.com/documentation/extensions/avatax-magento-2-module</a>.</p>
                    ]]></comment>
                <field id="enabled" translate="label" type="select" sortOrder="1000" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Enable AvaTax</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
                <field id="tax_settings_header" translate="label" type="label" sortOrder="1001" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label><![CDATA[<strong>Tax Calculation Settings</strong>]]></label>
                </field>
                <field id="tax_mode" translate="label" type="select" sortOrder="1002" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Tax Mode</label>
                    <source_model>ClassyLlama\AvaTax\Model\Config\Source\TaxMode</source_model>
                    <comment><![CDATA[<ul><li><strong>Disabled</strong> — AvaTax tax estimation will be disabled and native Magento tax estimation will be used. Only use this option if you want to use Address Validation without tax estimation.</li><li><strong>Estimate Tax</strong> — AvaTax tax estimation will run during checkout, but completed orders will not be submitted to AvaTax.</li><li><strong>Estimate Tax & Submit Transactions to AvaTax</strong> — AvaTax tax estimation will run during checkout and invoices and credit memos will be submitted to AvaTax.</li></ul>]]></comment>
                    <depends>
                        <field id="enabled">1</field>
                    </depends>
                </field>
                <field id="commit_submitted_transactions" translate="label" type="select" sortOrder="1004" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Commit Submitted Transactions</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment><![CDATA[Should transactions sent to AvaTax be committed? Only change to <strong>No</strong> if you have specific reason to do so.]]></comment>
                    <depends>
                        <field id="enabled">1</field>
                        <field id="tax_mode">3</field>
                    </depends>
                </field>
                <field id="tax_calculation_countries_enabled" translate="label comment" type="multiselect" sortOrder="1005" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Taxable Countries</label>
                    <source_model>ClassyLlama\AvaTax\Model\Config\Source\TaxCalculationCountries</source_model>
                    <comment><![CDATA[Select which countries to enable for tax calculation (address verification countries are <a href="#row_tax_avatax_address_validation_header">configured below</a>).]]></comment>
                    <depends>
                        <field id="enabled">1</field>
                        <field id="tax_mode" negative="1">1</field>
                    </depends>
                </field>
                <field id="filter_tax_by_region" translate="label" type="select" sortOrder="1006" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Filter Tax Calculation By Region</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment><![CDATA[Should tax calculation only apply to certain regions? Only change this to <strong>Yes</strong> if you have a specific reason to do so. See the [documentation](https://github.com/classyllama/ClassyLlama_AvaTax/blob/develop/docs/sales-tax.md#filter_by_region) for more details.]]></comment>
                    <depends>
                        <field id="enabled">1</field>
                        <field id="tax_mode" negative="1">1</field>
                    </depends>
                </field>
            </group>
        </section>
    </system>
</config>

app/etc/config.php

<?php
return [
    'system' => [
        'default' => [
            'tax' => [
                'avatax' => [
                    'enabled' => 1,
                    'tax_mode' => 3,
                    'commit_submitted_transactions' => 1,
                    'tax_calculation_countries_enabled' => 'US',
                    'filter_tax_by_region' => 0,
                    'upc_attribute' => 'upc'
                ]
            ]
        ]
    ]
];

Expected result

  1. The field "Tax mode" should be disabled and should not be able to get changed by the user.

Actual result

  1. Fields can be changed in the stores -> configuration section of the Magento backend, see screenshot:
    image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: ConfigEvent: mm19plIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: ready for devReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions