1

I want to add new tab to order_view and customer_edit pages from my extension. Can someone explain or write example how i can do this?

1 Answer 1

3

In your module (app/code/[Vendor]/[ModuleName]/) create view/adminhtml/layout/customer_index_edit.xml that contains something like

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="customer_form">
            <block class="[Vendor]\[ModuleName]\Block\Adminhtml\NewTab" name="newtab">
                <action method="setTabLabel">
                    <argument name="label" xsi:type="string">New Tab Label</argument>
                </action>
            </block>
        </referenceBlock>
    </body>
</page>

Then create your tab block file Block/Adminhtml/NewTab.php containing something similiar to;

<?php

namespace [Vendor]\[ModuleName]\Block\Adminhtml;

use Magento\Ui\Component\Layout\Tabs\TabWrapper;
use Magento\Ui\Component\Layout\Tabs\TabInterface;

class NewTab extends TabWrapper implements TabInterface
{
    public function canShowTab()
    {
        return true;
    }
}

That should get your started. Remember to clear your cache so the new config is picked up.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.