Quantcast
Channel: Framework – Mydons
Viewing all articles
Browse latest Browse all 47

Magento 2 How to add Custom tab to customer edit page

$
0
0

In Magento 2 to add a custom tab to customer edit page in Admin panel we need to follow the below approach.
The solution approach is slightly different when compared to Magento 1.X version, here we will be using the UI Component.

First create a file called customer_form.xml in Mydons/CustomTab/view/base/view/base/ui_component/customer_form.xml
(file name should be customer_form.xml as this is a convention).
Inside this file we can create and include the custom block under htmlContent Component

HtmlContent Component Overview

The htmlContent UI component will provide the ability to process and render a layout structure or place a Magento block directly inside a UI component configuration.

As per the above Definition we can define our custom block inside the htmlContent UI Component.
[crayon-5bae2dbc71638019717311/]

Creating the custom block and template

In Order to render the custom tab, we need to create the custom block first.
The CustomTab Class should implement the TabInterface methods like getTabLabel etc.

File Path: Mydons/CustomTab/Block/Adminhtml/CustomTab.php
[crayon-5bae2dbc7164f768982881/]

Template file creation for custom block

Create the Template file for displaying the actual contents.
File Path: Mydons/CustomTab/view/adminhtml/templates/tab/customtab.phtml
[crayon-5bae2dbc7165e012350896/]

Custom tab display

Suppose in Case if you need to move the tab position, we can achieve this by modifying the customer_form.xml

[crayon-5bae2dbc71669097200968/]

After applying the sorting for the custom tab

The post Magento 2 How to add Custom tab to customer edit page appeared first on Mydons.


Viewing all articles
Browse latest Browse all 47

Trending Articles