I want to override following file in my custom module:


How can I do that?

2 Answers 2


You have to create a module for this.

Using plugin on class Magento\Backend\Block\Widget\Button over getTemplate method, you can achieve your requirement.

Plugin class WidgetButtonPlugin.php located at app\code\{Vendorname}\{CompanyName}\Plugin\Block.

Plugin class code look like


namespace {Vendorname}\{CompanyName}\Plugin\Block;

class WidgetButtonPlugin

    public function aftergetTemplate(
        \Magento\Backend\Block\Widget\Button $subject,
    ) {

        return '{Vendorname}_{CompanyName}::widget/button.phtml';


Plugin's di.xml should be located at app\code\{Vendorname}\{CompanyName}\etc.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Backend\Block\Widget\Button">
        <plugin name="changes_button_template_file_for_widget" sortOrder="1"
                type="{Vendorname}\{CompanyName}\Plugin\Block\WidgetButtonPlugin" />


As per as, plugin new template should be located at


  • I try that soon, thx! Commented Jun 19, 2018 at 12:22

Try to add your custom admin theme

Create an Admin theme

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.