3

I've added a tab to the admin menu with our company's page, which enables the user to insert and define his own properties of our widget (input fields of secret and key). Now I would like magento's server to save these values upon clicking the page's 'save' button, and show them next time the user loads the page. previously we did that inside system.xml:

 field id="key" translate="label" type="text" showInDefault="1" showInStore="1">
 field id="secret" translate="label" type="text" showInDefault="1" showInStore="1">

I tried to translate this to .phtml (simple html input text) but not sure magento2 supports other formats except her attributes in xml files.

Ideas?

Amit Bera
77.8k21 gold badges127 silver badges240 bronze badges
asked Nov 16, 2015 at 9:36

1 Answer 1

1

enter image description hereIn Magento 2, you can achieve this by using the same system.xml file placed under app/code/Vendor/Package/etc/adminhtml/system.xml

<?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>
 <tab id="custom_module" translate="label" sortOrder="10">
 <label>Progos</label>
 </tab>
 <section id="custom_module_section" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
 <label>Custom Module</label>
 <tab>custom_module</tab>
 <resource>Progos_Custom::custom_config</resource>
 <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
 <label>API Settings</label>
 <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
 <label>Module Enable</label>
 <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
 </field>
 <field id="api" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
 <label>API</label>
 <comment>This is comment for this field.</comment>
 </field>
 <field id="secret" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
 <label>Secret Key</label>
 <comment>This is comment for this field.</comment>
 </field>
 </group>
 </section>
 </system> </config>

Please have a look at attached image too.

If you still have any confusion, let us know! Good Luck!

Adnan
8538 silver badges18 bronze badges
answered Aug 6, 2018 at 20:02

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.