cancel
Showing results for 
Search instead for 
Did you mean: 

Custom configuration fields (store scoped) for a payment module

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Custom configuration fields (store scoped) for a payment module

Hi,

 

I got some custom configuration fields working for a non-payment module, but have problems when i do the same for a payment module.

 

My issue is that the settting are readonly in the user interface (at every level of scope)

I cannot untick the tick box to change the default from the previous level.

 

I have the settings marked as sensitive and environmental too.

I've been able to set it with the command bin/magento config:set --scope=stores which seems odd seeing as it's supposed to be sensitive. However it's still not showing up in the admin ui.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Custom configuration fields (store scoped) for a payment module

So the reason for tick box being read-only was because the fields were sensitive/environmental.

 

Seems like a design decision that's not mentioned anywhere

 

View solution in original post

8 REPLIES 8

Re: Custom configuration fields (store scoped) for a payment module

Hi @martin_alley 

 

Check the values of these showInDefault, showInWebsite, showInStore in system.xml and verify if these attributes has value 1 others set their values as 1.

 

                <field id="title" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">

 Like this.

 

Thanks

---
If you've found my answer useful, please give"Kudos" and "Accept as Solution".

Re: Custom configuration fields (store scoped) for a payment module

                <field id="field1" translate="label" type="text" sortOrder="24" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Field1</label>
                </field>
                <field id="field2" translate="label" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Field2</label>
                </field>
                <field id="field3" translate="label" type="text" sortOrder="26" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Field3</label>
                </field>

Re: Custom configuration fields (store scoped) for a payment module

Hello @martin_alley 

 

I can be of more help if you may provide the screenshot of the issue.

 

Thanks.

---
If you've found my answer useful, please give"Kudos" and "Accept as Solution"

Re: Custom configuration fields (store scoped) for a payment module

If I run the cli config:sensitive:set, the config value is stored successfully in app/etc/env.php

However I need to set it via the web ui.

Here's a screen shot of the config section page (store view) You can see that the check box is disabled, stopping me from setting the field at store scopemagentoconfig.png

Re: Custom configuration fields (store scoped) for a payment module

Hello @martin_alley again!

 

I won't be able to see the screenshot until and unless the moderator approves it. Please can you share the screenshot in the form of a link?

---
If you've found my answer useful, please give"Kudos" and "Accept as Solution"

Re: Custom configuration fields (store scoped) for a payment module

I prefer to keep the screenshot on here only.

 

The problem is that Stores Configuration section, no matter what scope I show, the configuration is readonly. Where there is a tick box "Use Default" that tick box is also disabled.

 

 

Re: Custom configuration fields (store scoped) for a payment module

In my experiments I changed the default values in config.xml, however this didn't cause the values in app/etc/config.php to change. 

 

I ended up editing config.php manually, where upon the website gave me an error and told me to run cron:run.

 

What is the proper way to get config.php to update with new default values?

 

Investigating the readonly checkbox, I was looking at  module-config m-Model/Config/Reader/Source/Deployed/SettingChecker.php. The isReadOnly function returns true if there's a value for the config path - this seems a bit bizarre.

 

isReadOnly is called from module-config/Block/System/Config/Form.php. When adding a field (line 362 in function _initElement) it sets the following attributes

     'can_use_default_value' => $this->canUseDefaultValue($field->showInDefault()),
     'can_use_website_value' => $this->canUseWebsiteValue($field->showInWebsite()),
     'can_restore_to_default' => $this->isCanRestoreToDefault($field->canRestore()),

I'm thinking between them, these settings affect whether the tick box is enabled or not, but I've not followed it through yet.

 

Anyone been here before?

Thanks

Martin

 

Re: Custom configuration fields (store scoped) for a payment module

So the reason for tick box being read-only was because the fields were sensitive/environmental.

 

Seems like a design decision that's not mentioned anywhere