Skip to content

Fatal error: Class 'Vendor\Module\Block\Form\Entity\GenericButton' not found in app/code/Vendor/Module/Block/Adminhtml/Form/Button.php #2555

Open
@ioweb-gr

Description

@ioweb-gr

Describe the bug (*)

I've created a form with the form ui component tool however the form is not usable due to a Fatal Error.

The button added tries to extend Block\Form\Entity\GenericButton but that class is not created by the plugin.

THis is what the button code looks like

<?php
/**
 * Copyright (c) 2025. YourCompanyName
 */

namespace Vendor\ModuleName\Block\Adminhtml\Form;

use Vendor\ModuleName\Block\Form\Entity\GenericButton;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

/**
 * Save entity button.
 */
class Button extends GenericButton implements ButtonProviderInterface
{
    /**
     * Retrieve Save button settings.
     *
     * @return array
     */
    public function getButtonData(): array
    {
        return $this->wrapButtonSettings(
            __('Save')->getText(),
            'save primary',
            '',
            [
                'mage-init' => ['button' => ['event' => 'save']],
                'form-role' => 'save'
            ],
            30
        );
    }
}

To Reproduce (*)

Steps to reproduce the behavior:

  1. Go to New
  2. Click on Magento 2 UI Compoent form
  3. Make sure to add a button
  4. Try to visit the controller URL to render the form
  5. See the Fatal Error

Expected behavior (*)

There's no error and the Generic Button class exists.

Screenshots

If applicable, add screenshots to help explain your problem.

Please complete the following information: (*)

  • OS: Windows 11 x64
  • PhpStorm/Intellij version: 2025.1.1
  • Plugin Version: 2025.1.1

Additional context

Activity

m2-assistant

m2-assistant commented on Jun 3, 2025

@m2-assistant

Hi @ioweb-gr. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.
Add a comment to assign the issue: @magento I am working on this


Join Magento Community Engineering Slack and ask your questions in #github channel.

ioweb-gr

ioweb-gr commented on Jun 17, 2025

@ioweb-gr
Author

This is a sample diff to make it work . Basically remove the extends and don't use wrapButtonSettings but just return the array

diff --git a/app/code/Ioweb/Reporting/Block/Adminhtml/Form/OrderReport/Button.php b/app/code/Ioweb/Reporting/Block/Adminhtml/Form/OrderReport/Button.php
index 4b562e05f..140e620b3 100644
--- a/app/code/Ioweb/Reporting/Block/Adminhtml/Form/OrderReport/Button.php
+++ b/app/code/Ioweb/Reporting/Block/Adminhtml/Form/OrderReport/Button.php
@@ -11,7 +11,7 @@ use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
 /**
  * Save entity button.
  */
-class Button extends GenericButton implements ButtonProviderInterface 
+class Button implements ButtonProviderInterface
 {
     /**
      * Retrieve Save button settings.
@@ -20,15 +20,15 @@ class Button extends GenericButton implements ButtonProviderInterface
      */
     public function getButtonData(): array
     {
-        return $this->wrapButtonSettings(
-            __('Save')->getText(),
-            'save primary',
-            '',
-            [
+        return [
+            'label' => __('Save')->getText(),
+            'class' => 'save primary',
+            'on_click' => '',
+            'data_attribute' => [
                 'mage-init' => ['button' => ['event' => 'save']],
                 'form-role' => 'save'
             ],
-            30
-        );
+            'sort_order' => 30
+        ];
     }
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ioweb-gr

        Issue actions

          Fatal error: Class 'Vendor\Module\Block\Form\Entity\GenericButton' not found in app/code/Vendor/Module/Block/Adminhtml/Form/Button.php · Issue #2555 · magento/magento2-phpstorm-plugin