{"id":1770,"date":"2021-05-17T10:22:16","date_gmt":"2021-05-17T10:22:16","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/create-a-custom-tab-and-call-custom-phtml-in-product-ui-component-form-in-magento-2\/"},"modified":"2025-07-16T17:50:28","modified_gmt":"2025-07-16T12:20:28","slug":"create-a-custom-tab-and-call-custom-phtml-in-product-ui-component-form-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/create-a-custom-tab-and-call-custom-phtml-in-product-ui-component-form-in-magento-2\/","title":{"rendered":"How to Create a Custom Tab and Call Custom Phtml in Product UI-Component Form in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2\u00a0CMS not only facilitates users to customize the default features but also to add new features, buttons, forms, tabs, or any components in order to provide advanced functionalities that improve the store in terms of performance, administration, customer experience, etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You may develop&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-extensions.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 extensions<\/a>&nbsp;that extend such custom features in the online store.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While developing such extensions, you may require to&nbsp;<em><strong>create a custom tab and call custom phtml in product UI-component form in Magento 2&nbsp;<\/strong><\/em>to take any input value from the admin. Likewise if you want to hide the unnecessary tabs in the product page frontend then&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/hide-empty-custom-tab-in-magento-2\/\">Magento 2 hide an empty custom tab<\/a>&nbsp;will help to not let your customers distract from their main goal that is purchasing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The product UI-component form in Magento 2 allows the admin to create different&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-product-types\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 product types&nbsp;<\/a>such as&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/create-simple-product-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">simple<\/a>,&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-create-configurable-product\/\" target=\"_blank\" rel=\"noreferrer noopener\">configurable<\/a>,&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/create-virtual-products-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">virtual<\/a>,&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/create-downloadable-products-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">downloadable<\/a>,&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-create-bundle-product\/\" target=\"_blank\" rel=\"noreferrer noopener\">bundle<\/a>&nbsp;products, and edit them from the backend&nbsp;<strong>Catalog &gt; Products &gt; Product edit form<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The \u2018product edit form\u2019 offers various tabs by default. However, these default tabs are not always enough to meet the business requirement. The store owner may require an additional tab to upload a CSV file or enable\/disable the custom module that offers product-specific features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example,<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/05\/Screenshot-at-May-8th-2021-5.59.17-pm@1.25x-1024x291.png\" alt=\"How to Create a Custom Tab and Call Custom Phtml in Product UI-Component Form in Magento 2\" class=\"wp-image-14813\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Check out the below solution and add your required customized components under the custom tab.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, if you may need to&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/add-custom-button-in-admin-product-ui-component-form-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">, you can refer to my solution.<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Create a Custom Tab and Call Custom Phtml in Product UI-Component Form in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create the&nbsp;<strong>product_form.xml<\/strong>&nbsp;file at&nbsp;<strong>app\/code\/Vendor\/Module\/view\/adminhtml\/ui_component<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?>\n&lt;form xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n      xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Ui:etc\/ui_configuration.xsd\">\n    &lt;fieldset name=\"custom_tab\">\n        &lt;argument name=\"data\" xsi:type=\"array\">\n            &lt;item name=\"config\" xsi:type=\"array\">\n                &lt;item name=\"label\" xsi:type=\"string\" translate=\"true\">Custom tab&lt;\/item>\n                &lt;item name=\"collapsible\" xsi:type=\"boolean\">true&lt;\/item>\n                &lt;item name=\"opened\" xsi:type=\"boolean\">true&lt;\/item>\n                &lt;item name=\"canShow\" xsi:type=\"boolean\">true&lt;\/item>\n                &lt;item name=\"sortOrder\" xsi:type=\"string\">1&lt;\/item>\n            &lt;\/item>\n        &lt;\/argument>\n        &lt;container name=\"custom_tab_container\">\n            &lt;argument name=\"data\" xsi:type=\"array\">\n                &lt;item name=\"config\" xsi:type=\"array\">\n                    &lt;item name=\"sortOrder\" xsi:type=\"string\">1&lt;\/item>\n                &lt;\/item>\n            &lt;\/argument>\n            &lt;htmlContent name=\"html_content\">\n                &lt;argument name=\"block\" xsi:type=\"object\">Vendor\\Module\\Block\\Adminhtml\\Product\\CustomTab&lt;\/argument>\n            &lt;\/htmlContent>\n        &lt;\/container>\n    &lt;\/fieldset>\n&lt;\/form><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create the&nbsp;<strong>CustomTab.php&nbsp;<\/strong>file at<strong><strong>&nbsp;<\/strong>app\/code\/Vendor\/Module\/Block\/Adminhtml\/Product<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nnamespace Vendor\\Module\\Block\\Adminhtml\\Product;\nuse Magento\\Backend\\Block\\Template;\n\nclass CustomTab extends Template\n{\n    protected $_template = 'custom_tab.phtml';\n\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. Create the&nbsp;<strong>custom_tab.phtml&nbsp;<\/strong>file at&nbsp;<strong>app\/code\/Vendor\/Module\/view\/adminhtml\/templates<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\necho \"coustom tab\";\n?><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The custom tab in the product UI-component form looks as shown below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/05\/Screenshot-at-May-7th-2021-12.51.21-pm-1-1024x386.png\" alt=\"screenshot\" class=\"wp-image-14790\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, do share the post with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2\u00a0CMS not only facilitates users to customize the default features but also to add new features, buttons, forms, tabs, or any components in order&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1770","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1770"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1770\/revisions"}],"predecessor-version":[{"id":18076,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1770\/revisions\/18076"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}