I created an admin menu in magento2 which is linked to a new admin page. I would like to have my own configuration fields (some text fields) in this new page with a save button.
1 Answer 1
In your custom module create system.xml file on follwing path /app/code/Namespace/Module/etc/adminhtml/system.xml and add following code
<?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="tops" translate="label" sortOrder="10">
<label>Delivery Message</label>
</tab>
<section id="cod" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>Delivery message</label>
<tab>tops</tab>
<resource>Namespace_Module::cod_config</resource>
<group id="catalog" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>General Configuration</label>
<field id="codenable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Display Text</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="display_text" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Text for delivery message</label>
<comment>This text will display on the product detail page under addto cart button.</comment>
</field>
</group>
</section>
<section id="category_slider" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>Category Slider</label>
<tab>tops</tab>
<resource>Namespace_Module::cod_config</resource>
<group id="catalog_category" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>General Configuration</label>
<field id="category_id" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Please enter category ids comma saperated.</label>
<comment>Only first 2 ids data will display on home page.</comment>
</field>
</group>
</section>
</system>
</config>
Now go to Stoere->Configuration you will get your section called Delivery Message
-
I created a new menu like 'Store' and created a page with link.How can I add the above mentioned code under that menu link opening page?Ragesh VP– Ragesh VP2018年11月14日 08:48:01 +00:00Commented Nov 14, 2018 at 8:48
-
You need this section in configuration area or your custom page ?user55548– user555482018年11月14日 09:11:32 +00:00Commented Nov 14, 2018 at 9:11
-
yes.Custom page with a menu optionRagesh VP– Ragesh VP2018年11月14日 09:42:03 +00:00Commented Nov 14, 2018 at 9:42
-
I create a menu which is linked to a new admin page. I would like to have my own configuration fields in this new page with a save buttonRagesh VP– Ragesh VP2018年11月14日 09:47:27 +00:00Commented Nov 14, 2018 at 9:47
-
In that case you need to create model, and table for save your data.user55548– user555482018年11月14日 10:55:48 +00:00Commented Nov 14, 2018 at 10:55
Explore related questions
See similar questions with these tags.