Admin Configuration form in magento2 - Magento Source24

 

Admin Configuration form in magento2

Hello Magento friends here we are create a Admin Configuration form in magento2  : 


<?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="carriers" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="1000" translate="label">
            <group id="deliverydateandtime" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label">
                <label>Pickup Date Shipping Method Group</label>
                <field id="active" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label" type="select" canRestore="1">
                    <label>Enabled</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
                <field id="name" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="20" translate="label" type="text" canRestore="1">
                    <label>Method Name</label>
                </field>
                <field id="price" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="30" translate="label" type="text" canRestore="1">
                    <label>Price</label>
                    <validate>validate-number</validate>
                </field>
                <field id="sort_order" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="51" translate="label" type="text">
                    <label>Sort Order</label>
                </field>
                <field id="title" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="50" translate="label" type="text" canRestore="1">
                    <label>Title</label>
                </field>
                <field id="format" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
                    <label>Date Format:</label>
                    <comment>yy-mm-dd</comment>
                </field>
                <field id="startdate" translate="label" type="text" sortOrder="11" showInDefault="1" showInWebsite="1" canRestore="1" showInStore="1">
                    <label>Start Date of the Slot</label>
                    <comment>today-today, tommarow:+1d, next day to strat :+1d,+2d,+3d,+4d</comment>
                </field>
                <field id="starttimne" translate="label" sortOrder="12" type="time" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Start Time of the Slot</label>
                </field>
                <field id="enddate" translate="label" type="text" sortOrder="13" showInDefault="1" showInWebsite="1" canRestore="1" showInStore="1">
                    <label>End Date of the Slot</label>
                    <comment>today-today, tommarow:+1d, next day to strat :+1d,+2d,+3d,+4d</comment>
                </field>
                <field id="optiondeliverytime" translate="label" type="multiselect" sortOrder="14" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Delivery Time Options </label>
                    <source_model>SR\DeliveryDate\Model\Adminhtml\System\Config\Source\DeliveryTime</source_model>
                    <can_be_empty>1</can_be_empty>
                </field>
                <field id="cutofminute" translate="label" type="text" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
                    <label>Cut of Time:</label>
                    <comment>in minute</comment>
                </field>
            </group>
        </section>
    </system>
</config>

 this is file is default  config.xml it is used to set deault value of above form 

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <carriers>
            <deliverydateandtime>
                <format>yy-mm-dd</format>
                <disabled>-1</disabled>
                <hourMin>8</hourMin>
                <hourMax>22</hourMax>
                <active>1</active>
                <startdate>+1d</startdate>
                <enddate>+7d</enddate>
                <cutofminute>59</cutofminute>
                <sallowspecific>0</sallowspecific>
                <model>SR\DeliveryDate\Model\Carrier\Shipping</model>
                <name>Pickup Rate</name>
                <title>Pickup Date and Time</title>
                <price>10</price>
                <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg>
                <handling_type>F</handling_type>
            </deliverydateandtime>
        </carriers>
    </default>
</config>



Deepak Kumar Bind

Success is peace of mind, which is a direct result of self-satisfaction in knowing you made the effort to become the best of which you are capable.

Post a Comment

If you liked this post please do not forget to leave a comment. Thanks

Previous Post Next Post