I want to add a tab on User edit page which can be accessed from grid in section System -> All users. I have managed to add tab but it is not loading through AJAX. When I click on tab it redirects to another URL.
Please see screen shot and code below.
Code:-
/app/code/Namespace/Module/Block/Adminhtml/Edit/Tab/Customer.php
<?php
namespace Namespace\Module\Block\Adminhtml\Edit\Tab;
class Customer extends \Magento\Backend\Block\Widget\Tabs
{
/**
* Class constructor
*
* @return void
*/
protected function _construct()
{
parent::_construct();
$this->setId('page_tabs');
$this->setDestElementId('edit_form');
}
/**
* @return $this
*/
protected function _beforeToHtml()
{
$this->addTab(
'magcr_customer_section',
[
'label' => __('Select Customer(s)'),
'title' => __('Select Customer(s)'),
'url' => $this->getUrl('magcr/index/customer'),
'class' => 'ajax',
'active' => FALSE
]
);
return parent::_beforeToHtml();
}
}
/app/code/Namespace/Module/view/adminhtml/layout/adminhtml_user_edit.xml
<?xml version="1.0"?>
<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>
<referenceContainer name="left">
<block class="Namespace\Module\Block\Adminhtml\Edit\Tab\Customer" name="adminhtml.user.edit.tabs1"/>
</referenceContainer>
</body>
</page>
Please help what am I doing wrong.
UPDATE
When I modify below code in constructor of block class, the tabs loads through ajax.
$this->setId('magcr_page_tabs');
But now problem is both 'User Info' and 'Select Customer(s)' load automatically on page load.