I want to create a new tab under User Role
tab.
Can anyone help me on how to create those types of tab in admin panel. Please !!
For example,
You have to create new module and layout file adminhtml_user_edit.
Namespace/Module/view/adminhtml/layout/adminhtml_user_edit.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="adminhtml.user.editroles">
<block class="Namespace\ModuleName\Block\Adminhtml\Role\Tab\Scope" name="adminhtml.user.tab.test.scope"/>
<action method="addTabAfter">
<argument name="name" xsi:type="string">amrolepermissions.scope</argument>
<argument name="block" xsi:type="string">adminhtml.user.tab.test.scope</argument>
<argument name="after" xsi:type="string">roles</argument>
</action>
</referenceBlock>
</body>
Please create this block
NameSpace/ModuleName/Block/Adminhtml/Role/Tab/Scope
namespace yourNameSpace\yourModuleName\Block\Adminhtml\Role\Tab;
class Scope extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface
{
const MODE_NONE = 0;
const MODE_SITE = 1;
const MODE_VIEW = 2;
/**
* @var \Magento\Store\Model\System\Store
*/
protected $_systemStore;
/**
* @var \Magento\Config\Model\Config\Source\Yesno
*/
private $optionList;
/**
* @var \Magento\Config\Model\Config\Structure\Element\Dependency\FieldFactory
*/
private $fieldFactory;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
\Magento\Store\Model\System\Store $systemStore,
\Magento\Config\Model\Config\Source\Yesno $optionList,
\Magento\Config\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory,
array $data = []
) {
$this->_systemStore = $systemStore;
$this->optionList = $optionList;
$this->fieldFactory = $fieldFactory;
parent::__construct($context, $registry, $formFactory, $data);
}
/**
* Get tab label
*
* @return \Magento\Framework\Phrase
*/
public function getTabLabel()
{
return __('Advanced: Scope');
}
/**
* Get tab title
*
* @return string
*/
public function getTabTitle()
{
return $this->getTabLabel();
}
/**
* Whether tab is available
*
* @return bool
*/
public function canShowTab()
{
return true;
}
/**
* Whether tab is visible
*
* @return bool
*/
public function isHidden()
{
return false;
}
}