Categories
Magento

How to Add Custom Tab in Customer Form in Magento 2

In this editorial, we will learn how to add custom tab in admin customer form in magento 2.

The customer form mainly contains “Customer View”, “Account Information”, “Whishlist” and “Orders” sections. To add a custom tab to the customer form in Magento 2, follow the below steps:

Create customer_index_edit.xml file at app/code/Vendor_Name/Module_Name/view/adminhtml/layout/customer_index_edit.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <uiComponent name="customer_form"/>
        </referenceContainer>
    </body>
</page>

Create customer_form.xml file at app/code/Vendor_Name/Module_Name/view/adminhtml/ui_component/customer_form.xml

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="amit-demo-tab">
        <settings>
            <collapsible>false</collapsible>
            <label translate="true">Demo Tab</label>
            <componentType>fieldset</componentType>
            <additionalClasses>
                <class name="customer-demo-form">true</class>
            </additionalClasses>
        </settings>
    </fieldset>
</form>

I hope this article on adding a custom tab to
the Magento 2 customer form in admin is simple to grasp.

If you still have any issue feel free to ask and let me know your views to make the better. Share this solution with your other Magento buddies via social media.

Thanks for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *