HOW TO CREATE A TAB IN Admin CUSTOMER EDIT PAGE IN MAGENTO 2?

In Magento 2, You can add a new custom tab in the Customer Edit page. If you want to add a new tab in Customer edit section for your custom requirement, You can add easily customer tab in Customer edit section.

You need to create a simple module for add extra tab in the customer edit section.

Refer below code snippet for add extra tab,
I have taken Rbj as Packagename and CustomerTab as modulename for simplicity.

You need to create first registration.php and module.xml file for defining our module.
Path: app/code/Rbj/CustomerTab/registration.php

Create module.xml file, Path: app/code/Rbj/CustomerTab/etc/module.xml

We have added a dependency for Magento Customer Module for add a new tab in the customer edit page. So we have defined Magento_Customer module in sequence tag in an above XML file.

Now comes to the main entry point of a module,
For Add new tab, We must override customer_index_edit.xml file to add our logic of add custom tabs.

referenceBlock customer_form contains the tab lists for customer edit section page.
We have declared Rbj\CustomerTab\Block\Adminhtml\CustomerEdit\Tab\View.php file as Block file.

So we need to create a customer_index_edit.xml file in our module at below path,
Path: app/code/Rbj/CustomerTab/view/adminhtml/layout/customer_index_edit.xml

In the above file, We have declared Block file for set your custom logic, which you want to display in custom tabs of the customer edit page.

Create a New Block PHP file,
Path: app/code/Rbj/CustomerTab/Block/Adminhtml/CustomerEdit/Tab/View.php

Above file, We can declared template file using $_template variable.

protected $_template = ‘tab/customer_view.phtml’ used for template file for our custom tabs.

You can set Custom Tab label by getTabLabel() and set title using getTabTitle() function.You can define custom function for your requirement in above file.

If you want to show content of your custom tab via ajax, you need to return true for isAjaxLoaded() function.

You can get Current customer data by calling Magento\Framework\Registry object.

Now we need to create template file, Path: app/code/Rbj/CustomerTab/view/adminhtml/templates/tab/customer_view.phtml

Now Run Upgrade command to install our module.
php bin/magento setup:upgrade
php bin/magento cache:flush
php bin/magento indexer:reindex customer_grid

Now Go To Admin panel,
Login with your credentials,
Click on Left Sidebar, Customers -> All Customers Link,
Click on Any Customer, You can show tab as your new custom tab in the Customer edit page.

customer tab
customer tab

Your new tab will be available in the customer edit page.