5

I created a custom tab for customer edit page in backend like this:

app/code/Namespace/Module/view/adminhtml/layout/customer_index_edit.xml

<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="Namespace\Module\Block\Adminhtml\Edit\Tab\Vcard" name="customer_edit_tab_vcard" >
              <action method="setTabLabel">
                  <argument name="label" xsi:type="string">V-Card</argument>
              </action>
            </block>
          </referenceBlock>
    </body>
</page>

When i opened the customer edit page, the first tab that is active is Customer View

example

How can i set my custom tab that is active?

6
  • Do you mean you want set your custom tab as active by default when you edit any customer? Jun 19, 2019 at 9:09
  • @SukumarGorai yes, to be precise i'll add get param to the url , when this get param exist in the url , my custom tab will be active
    – blue
    Jun 19, 2019 at 9:12
  • So when you will get param from url then only your tab will show active. Is it correct? Jun 19, 2019 at 9:13
  • @SukumarGorai yes that is correct , for example mage2.loc/admin/customer/index/edit/id/118/vcard/1/key/… , the param will be vcard
    – blue
    Jun 19, 2019 at 9:25
  • @blue have u got a solution for this ?
    – chris
    Jun 20, 2020 at 13:53

1 Answer 1

1

In Magento 2 backend forms, by default, the active tab is set based on which module loads first in the sequence.

If you check addTab method in Magento\Backend\Block\Widget\Tab\TabInterface\Tab class you will see that logic setup first added tab to active status if the active tab does not determine.

1
  • so how can i set my tab to be active?
    – blue
    Jun 19, 2019 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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