Magento 2 – How to Position Custom Tab in Customer Edit Page in Admin Panel

admin-panelcustomcustomermagento2magento2.2

I created a custom tab in customer edit page in admin panel. It works perfectly, but I want to position the tab, so I tried to edit the customer_index_edit.xml file like below by adding:

<action method="addTabAfter">
    <argument name="after" xsi:type="string">wishlist</argument>
</action>

but it's not working and throwing an error:

[2017-10-09 05:56:42] main.CRITICAL: Invalid method vendor\module\Block\Adminhtml\Edit\Tab\Rewardpoints::addTabAfter

My customer_index_edit.xml file is below.

<?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>
    <referenceBlock name="customer_form">
         <block class="Vendor\Module\Block\Adminhtml\Edit\Tab\Rewardpoints" name="customer_edit_tab_rewardpoints">
            <action method="addTabAfter">
                 <argument name="after" xsi:type="string">wishlist</argument>
            </action>
         </block>   
    </referenceBlock> 
</body>
</page>

How to position the tab after wishlist tab in customer edit page in admin panel?

Best Answer

Add after="wishlist" in your custom link.

Your final new custom link code:

<referenceBlock name="customer_form">
     <block class="Vendor\Module\Block\Adminhtml\Edit\Tab\Rewardpoints" name="customer_edit_tab_rewardpoints" after="wishlist">
        <action method="setTabLabel">
            <argument name="label" xsi:type="string">Your Tab Label</argument>
        </action>
     </block>   
</referenceBlock>