How to add custom customer attribute in custom tab in customer edit page of admin in magento2












5















I have created custom customer attribute successfully. Which are showing under account information tab of customer edit in admin.



I want to show them in my custom tab.










share|improve this question

























  • found the solution for this?

    – SwAt.Be
    Mar 29 '18 at 2:52











  • Any body know solution ?

    – amit_game
    Jul 31 '18 at 5:55











  • I need a solution, too.

    – skymeissner
    Sep 28 '18 at 13:07











  • the attributes under the account information tab are rendered generically based on a setting you can add to the customer attribute (include in forms, it's an own mapping table). If you have a custom tab, you have to render it yourself, but the "how" depends on how you implemented the custom tab

    – David Verholen
    Jan 11 at 21:12


















5















I have created custom customer attribute successfully. Which are showing under account information tab of customer edit in admin.



I want to show them in my custom tab.










share|improve this question

























  • found the solution for this?

    – SwAt.Be
    Mar 29 '18 at 2:52











  • Any body know solution ?

    – amit_game
    Jul 31 '18 at 5:55











  • I need a solution, too.

    – skymeissner
    Sep 28 '18 at 13:07











  • the attributes under the account information tab are rendered generically based on a setting you can add to the customer attribute (include in forms, it's an own mapping table). If you have a custom tab, you have to render it yourself, but the "how" depends on how you implemented the custom tab

    – David Verholen
    Jan 11 at 21:12
















5












5








5








I have created custom customer attribute successfully. Which are showing under account information tab of customer edit in admin.



I want to show them in my custom tab.










share|improve this question
















I have created custom customer attribute successfully. Which are showing under account information tab of customer edit in admin.



I want to show them in my custom tab.







magento-2.1 php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 27 '17 at 12:25









Teja Bhagavan Kollepara

2,94841847




2,94841847










asked Jun 7 '17 at 13:36









Mohit chauhanMohit chauhan

526




526













  • found the solution for this?

    – SwAt.Be
    Mar 29 '18 at 2:52











  • Any body know solution ?

    – amit_game
    Jul 31 '18 at 5:55











  • I need a solution, too.

    – skymeissner
    Sep 28 '18 at 13:07











  • the attributes under the account information tab are rendered generically based on a setting you can add to the customer attribute (include in forms, it's an own mapping table). If you have a custom tab, you have to render it yourself, but the "how" depends on how you implemented the custom tab

    – David Verholen
    Jan 11 at 21:12





















  • found the solution for this?

    – SwAt.Be
    Mar 29 '18 at 2:52











  • Any body know solution ?

    – amit_game
    Jul 31 '18 at 5:55











  • I need a solution, too.

    – skymeissner
    Sep 28 '18 at 13:07











  • the attributes under the account information tab are rendered generically based on a setting you can add to the customer attribute (include in forms, it's an own mapping table). If you have a custom tab, you have to render it yourself, but the "how" depends on how you implemented the custom tab

    – David Verholen
    Jan 11 at 21:12



















found the solution for this?

– SwAt.Be
Mar 29 '18 at 2:52





found the solution for this?

– SwAt.Be
Mar 29 '18 at 2:52













Any body know solution ?

– amit_game
Jul 31 '18 at 5:55





Any body know solution ?

– amit_game
Jul 31 '18 at 5:55













I need a solution, too.

– skymeissner
Sep 28 '18 at 13:07





I need a solution, too.

– skymeissner
Sep 28 '18 at 13:07













the attributes under the account information tab are rendered generically based on a setting you can add to the customer attribute (include in forms, it's an own mapping table). If you have a custom tab, you have to render it yourself, but the "how" depends on how you implemented the custom tab

– David Verholen
Jan 11 at 21:12







the attributes under the account information tab are rendered generically based on a setting you can add to the customer attribute (include in forms, it's an own mapping table). If you have a custom tab, you have to render it yourself, but the "how" depends on how you implemented the custom tab

– David Verholen
Jan 11 at 21:12












1 Answer
1






active

oldest

votes


















0














To create a new tab in the admin customer edit, create a xml in the following path



Step 1:
/app/code/Vendorname/modulename/view/adminhtml/layout/customer_index_edit.xml



<body>
<referenceBlock name="customer_form">
<block class="VendornameModulenameBlockAdminhtmlEditTabTest" name="customer_edit_tab_test" >
<action method="setTabLabel">
<argument name="label" xsi:type="string">Test Tab</argument>
</action>
</block>
</referenceBlock>
</body>


Step 2:
Create a block file in the below path to load the contents when the tab is clicked



/app/code/Vendorname/Modulename/Block/Adminhtml/Edit/Tab/Test.php






namespace VendornameModulenameBlockAdminhtmlEditTab;



use MagentoCustomerControllerRegistryConstants;



use MagentoUiComponentLayoutTabsTabInterface;



class Test extends MagentoFrameworkViewElementTemplate implements TabInterface
{



protected $_coreRegistry;

public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
array $data =
) {
$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}

/**
* @return string|null
*/
public function getCustomerId()
{
return $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
}
/**
* @return MagentoFrameworkPhrase
*/
public function getTabLabel()
{
return __(‘Tab label’);
}
/**
* @return MagentoFrameworkPhrase
*/
public function getTabTitle()
{
return __(‘Tab Title’);
}
/**
* @return bool
*/
public function canShowTab()
{
if ($this->getCustomerId()) {
return true;
}
return false;
}

/**
* @return bool
*/
public function isHidden()
{
if ($this->getCustomerId()) {
return false;
}
return true;
}
/**
* Tab class getter
*
* @return string
*/
public function getTabClass()
{
return '';
}
/**
* Return URL link to Tab content
*
* @return string
*/
public function getTabUrl()
{
//replace the tab with the url you want
return $this->getUrl('test/*/test', ['_current' => true]);
}
/**
* Tab should be loaded trough Ajax call
*
* @return bool
*/
public function isAjaxLoaded()
{
return true;
}


}



Your new test tab will be added to customer edit left side menu.





share























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f177902%2fhow-to-add-custom-customer-attribute-in-custom-tab-in-customer-edit-page-of-admi%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    To create a new tab in the admin customer edit, create a xml in the following path



    Step 1:
    /app/code/Vendorname/modulename/view/adminhtml/layout/customer_index_edit.xml



    <body>
    <referenceBlock name="customer_form">
    <block class="VendornameModulenameBlockAdminhtmlEditTabTest" name="customer_edit_tab_test" >
    <action method="setTabLabel">
    <argument name="label" xsi:type="string">Test Tab</argument>
    </action>
    </block>
    </referenceBlock>
    </body>


    Step 2:
    Create a block file in the below path to load the contents when the tab is clicked



    /app/code/Vendorname/Modulename/Block/Adminhtml/Edit/Tab/Test.php






    namespace VendornameModulenameBlockAdminhtmlEditTab;



    use MagentoCustomerControllerRegistryConstants;



    use MagentoUiComponentLayoutTabsTabInterface;



    class Test extends MagentoFrameworkViewElementTemplate implements TabInterface
    {



    protected $_coreRegistry;

    public function __construct(
    MagentoBackendBlockTemplateContext $context,
    MagentoFrameworkRegistry $registry,
    array $data =
    ) {
    $this->_coreRegistry = $registry;
    parent::__construct($context, $data);
    }

    /**
    * @return string|null
    */
    public function getCustomerId()
    {
    return $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
    }
    /**
    * @return MagentoFrameworkPhrase
    */
    public function getTabLabel()
    {
    return __(‘Tab label’);
    }
    /**
    * @return MagentoFrameworkPhrase
    */
    public function getTabTitle()
    {
    return __(‘Tab Title’);
    }
    /**
    * @return bool
    */
    public function canShowTab()
    {
    if ($this->getCustomerId()) {
    return true;
    }
    return false;
    }

    /**
    * @return bool
    */
    public function isHidden()
    {
    if ($this->getCustomerId()) {
    return false;
    }
    return true;
    }
    /**
    * Tab class getter
    *
    * @return string
    */
    public function getTabClass()
    {
    return '';
    }
    /**
    * Return URL link to Tab content
    *
    * @return string
    */
    public function getTabUrl()
    {
    //replace the tab with the url you want
    return $this->getUrl('test/*/test', ['_current' => true]);
    }
    /**
    * Tab should be loaded trough Ajax call
    *
    * @return bool
    */
    public function isAjaxLoaded()
    {
    return true;
    }


    }



    Your new test tab will be added to customer edit left side menu.





    share




























      0














      To create a new tab in the admin customer edit, create a xml in the following path



      Step 1:
      /app/code/Vendorname/modulename/view/adminhtml/layout/customer_index_edit.xml



      <body>
      <referenceBlock name="customer_form">
      <block class="VendornameModulenameBlockAdminhtmlEditTabTest" name="customer_edit_tab_test" >
      <action method="setTabLabel">
      <argument name="label" xsi:type="string">Test Tab</argument>
      </action>
      </block>
      </referenceBlock>
      </body>


      Step 2:
      Create a block file in the below path to load the contents when the tab is clicked



      /app/code/Vendorname/Modulename/Block/Adminhtml/Edit/Tab/Test.php






      namespace VendornameModulenameBlockAdminhtmlEditTab;



      use MagentoCustomerControllerRegistryConstants;



      use MagentoUiComponentLayoutTabsTabInterface;



      class Test extends MagentoFrameworkViewElementTemplate implements TabInterface
      {



      protected $_coreRegistry;

      public function __construct(
      MagentoBackendBlockTemplateContext $context,
      MagentoFrameworkRegistry $registry,
      array $data =
      ) {
      $this->_coreRegistry = $registry;
      parent::__construct($context, $data);
      }

      /**
      * @return string|null
      */
      public function getCustomerId()
      {
      return $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
      }
      /**
      * @return MagentoFrameworkPhrase
      */
      public function getTabLabel()
      {
      return __(‘Tab label’);
      }
      /**
      * @return MagentoFrameworkPhrase
      */
      public function getTabTitle()
      {
      return __(‘Tab Title’);
      }
      /**
      * @return bool
      */
      public function canShowTab()
      {
      if ($this->getCustomerId()) {
      return true;
      }
      return false;
      }

      /**
      * @return bool
      */
      public function isHidden()
      {
      if ($this->getCustomerId()) {
      return false;
      }
      return true;
      }
      /**
      * Tab class getter
      *
      * @return string
      */
      public function getTabClass()
      {
      return '';
      }
      /**
      * Return URL link to Tab content
      *
      * @return string
      */
      public function getTabUrl()
      {
      //replace the tab with the url you want
      return $this->getUrl('test/*/test', ['_current' => true]);
      }
      /**
      * Tab should be loaded trough Ajax call
      *
      * @return bool
      */
      public function isAjaxLoaded()
      {
      return true;
      }


      }



      Your new test tab will be added to customer edit left side menu.





      share


























        0












        0








        0







        To create a new tab in the admin customer edit, create a xml in the following path



        Step 1:
        /app/code/Vendorname/modulename/view/adminhtml/layout/customer_index_edit.xml



        <body>
        <referenceBlock name="customer_form">
        <block class="VendornameModulenameBlockAdminhtmlEditTabTest" name="customer_edit_tab_test" >
        <action method="setTabLabel">
        <argument name="label" xsi:type="string">Test Tab</argument>
        </action>
        </block>
        </referenceBlock>
        </body>


        Step 2:
        Create a block file in the below path to load the contents when the tab is clicked



        /app/code/Vendorname/Modulename/Block/Adminhtml/Edit/Tab/Test.php






        namespace VendornameModulenameBlockAdminhtmlEditTab;



        use MagentoCustomerControllerRegistryConstants;



        use MagentoUiComponentLayoutTabsTabInterface;



        class Test extends MagentoFrameworkViewElementTemplate implements TabInterface
        {



        protected $_coreRegistry;

        public function __construct(
        MagentoBackendBlockTemplateContext $context,
        MagentoFrameworkRegistry $registry,
        array $data =
        ) {
        $this->_coreRegistry = $registry;
        parent::__construct($context, $data);
        }

        /**
        * @return string|null
        */
        public function getCustomerId()
        {
        return $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
        }
        /**
        * @return MagentoFrameworkPhrase
        */
        public function getTabLabel()
        {
        return __(‘Tab label’);
        }
        /**
        * @return MagentoFrameworkPhrase
        */
        public function getTabTitle()
        {
        return __(‘Tab Title’);
        }
        /**
        * @return bool
        */
        public function canShowTab()
        {
        if ($this->getCustomerId()) {
        return true;
        }
        return false;
        }

        /**
        * @return bool
        */
        public function isHidden()
        {
        if ($this->getCustomerId()) {
        return false;
        }
        return true;
        }
        /**
        * Tab class getter
        *
        * @return string
        */
        public function getTabClass()
        {
        return '';
        }
        /**
        * Return URL link to Tab content
        *
        * @return string
        */
        public function getTabUrl()
        {
        //replace the tab with the url you want
        return $this->getUrl('test/*/test', ['_current' => true]);
        }
        /**
        * Tab should be loaded trough Ajax call
        *
        * @return bool
        */
        public function isAjaxLoaded()
        {
        return true;
        }


        }



        Your new test tab will be added to customer edit left side menu.





        share













        To create a new tab in the admin customer edit, create a xml in the following path



        Step 1:
        /app/code/Vendorname/modulename/view/adminhtml/layout/customer_index_edit.xml



        <body>
        <referenceBlock name="customer_form">
        <block class="VendornameModulenameBlockAdminhtmlEditTabTest" name="customer_edit_tab_test" >
        <action method="setTabLabel">
        <argument name="label" xsi:type="string">Test Tab</argument>
        </action>
        </block>
        </referenceBlock>
        </body>


        Step 2:
        Create a block file in the below path to load the contents when the tab is clicked



        /app/code/Vendorname/Modulename/Block/Adminhtml/Edit/Tab/Test.php






        namespace VendornameModulenameBlockAdminhtmlEditTab;



        use MagentoCustomerControllerRegistryConstants;



        use MagentoUiComponentLayoutTabsTabInterface;



        class Test extends MagentoFrameworkViewElementTemplate implements TabInterface
        {



        protected $_coreRegistry;

        public function __construct(
        MagentoBackendBlockTemplateContext $context,
        MagentoFrameworkRegistry $registry,
        array $data =
        ) {
        $this->_coreRegistry = $registry;
        parent::__construct($context, $data);
        }

        /**
        * @return string|null
        */
        public function getCustomerId()
        {
        return $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
        }
        /**
        * @return MagentoFrameworkPhrase
        */
        public function getTabLabel()
        {
        return __(‘Tab label’);
        }
        /**
        * @return MagentoFrameworkPhrase
        */
        public function getTabTitle()
        {
        return __(‘Tab Title’);
        }
        /**
        * @return bool
        */
        public function canShowTab()
        {
        if ($this->getCustomerId()) {
        return true;
        }
        return false;
        }

        /**
        * @return bool
        */
        public function isHidden()
        {
        if ($this->getCustomerId()) {
        return false;
        }
        return true;
        }
        /**
        * Tab class getter
        *
        * @return string
        */
        public function getTabClass()
        {
        return '';
        }
        /**
        * Return URL link to Tab content
        *
        * @return string
        */
        public function getTabUrl()
        {
        //replace the tab with the url you want
        return $this->getUrl('test/*/test', ['_current' => true]);
        }
        /**
        * Tab should be loaded trough Ajax call
        *
        * @return bool
        */
        public function isAjaxLoaded()
        {
        return true;
        }


        }



        Your new test tab will be added to customer edit left side menu.






        share











        share


        share










        answered 5 mins ago









        nishunishu

        212




        212






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f177902%2fhow-to-add-custom-customer-attribute-in-custom-tab-in-customer-edit-page-of-admi%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Polycentropodidae

            Magento 2 Error message: Invalid state change requested

            Paulmy