How to Hide Ui Component Form Custom Tab in Admin in Magento2

In this article, we will learn how to add/remove tab according to condition in magento2. As per previous blog we create custom tab and load ui grid on it. Now to hide that tab we’ll follow some steps:

Create customer_form.xml file at app/code/Vendor_Name/Module_Name/view/adminhtml/layout/customer_index_edit.xml

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="demo-amit-tab" class="Vendor_Name\Module_Name\Ui\Component\Form\Product\Action">
            <label translate="true">Demo Tab</label>
                <class name="customer-warranty-form">true</class>

        <insertListing name="product_listing">
                    <link name="parent_id">${ $.externalProvider }:params.parent_id</link>
                    <link name="parent_id">${ $.provider }:data.customer.entity_id</link>
                    <link name="onAction">ns = ${ $.ns }, index = actions:action</link>
                    <link name="onMassAction">ns = ${ $.ns }, index = listing_massaction:massaction</link>

Create Action.php file at Vendor_Name\Module_Name\Ui\Component\Form\Product\Action.php

use Magento\Ui\Component\Listing\Columns\Column;
class Action extends Column
    public function prepare()
        if ($condition) { // Your condition goes here
            $status = true;
        $this->_data['config']['componentDisabled'] = $status; // for removing the tab

I hope this blog is resolve your issue easily.
If you still have any issue feel free to ask and let us know your views to make the better. Share this solution with your other Magento buddies via social media.

Thanks for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *