I've been working on a module to put a custom button, that opens a popup for input values, onto the Customer Edit page (customer/index/edit/id/) within the admin:
I've been using this for the module.xml :
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Foo_CustomerResetPass" setup_version="1.0.0">
<sequence>
<module name="Magento_Customer"/>
</sequence>
</module>
</config>
This for the Block :
<?php
namespace Foo\CustomerResetPass\Block\Adminhtml\Customer\Edit;
use Magento\Customer\Block\Adminhtml\Edit\GenericButton;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
/**
* Set Cust Pass button
*/
class Login extends GenericButton implements ButtonProviderInterface
{
/**
* @var \Magento\Framework\AuthorizationInterface
*/
protected $_authorization;
/**
* Constructor
*
* @param \Magento\Backend\Block\Widget\Context $context
* @param \Magento\Framework\Registry $registry
* @param AccountManagementInterface $customerAccountManagement
*/
public function __construct(
\Magento\Backend\Block\Widget\Context $context,
\Magento\Framework\Registry $registry
) {
parent::__construct($context, $registry);
$this->_authorization = $context->getAuthorization();
}
/**
* @return array
*/
public function getButtonData()
{
$customerId = $this->getCustomerId();
$data = [];
$canModify = $customerId && $this->_authorization->isAllowed('Foo_CustomerResetPass::reset_button');
if ($canModify) {
$data = [
'label' => __('Set Customer Password'),
'class' => 'reset reset-button',
'on_click' => 'window.open( \'' . $this->getInvalidateTokenUrl() .
'\')',
'sort_order' => 80,
];
}
return $data;
}
/**
* @return string
*/
public function getInvalidateTokenUrl()
{
return $this->getUrl('/foo/reset.php', ['customer_id' => $this->getCustomerId()]);
}
}
And this is for the index.xml under view/adminhtml/layout
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="formkey"/>
<update handle="resetpass_login_grid_block"/>
<body>
<referenceContainer name="content">
<block class="Foo\CustomerResetPass\Block\Adminhtml\ResetPass" name="resetpass.container"/>
</referenceContainer>
</body>
</page>
Any help or if anyone could point me in the right direction it would be greatly appreciated and thanks in advance!
Best Answer
Ok ... I found an answer create xml file on /view/adminhtml/ui_component/customer_form.xml
and one block