This happens because 'secret key' is missing when you just type in URL manually.
Secret key feature is enabled by default and can be disabled here: Stores => Configuration => Advanced => Admin => Security => Add Secret Key to URLs. Then you should be able to reach your action.
You can just use a "naked" input field, you just have to add the following attribute:
<input data-form-part="product_form" type="text" name="my_new_field" value="123">
You will then be able to get the POST data for your input.
In router.xml file (companyName/customModule/etc/adminhtml/router.xml) For me the solution was to have the route id and frontName have the same value. In your case this would be:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/...
isAllowed() is used to check if your controller(for specific method) is authorized for logged in user or not.
It by default returns true so you should define it to restrict from user.
As you can see, by default, this method returns true. That means if you don’t define your own _isAllowed method your Admin Panel features will be open to any user with an ...
In Magento 2 you need to create menu.xml file in your module's etc/adminhtml folder. Here is example of menu.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Backend/etc/menu.xsd">
<add id="Lapisbard_StoreLocator::storelocator" title="...
The solution above is not fully correct. You are adding a field as a "naked" html element and a product form is an UI form with its own peculiarities. A special class (vendor/magento/module-ui/view/base/web/js/form/form.js) is responsible for fields collection and their validation when a form is sent. Also, this class should miss the fields that are not ...
Visibility in the admin menu is not determined by the controller and its _isAllowed method but directly by the ACL. If you want the menu to be always visible and not controlled by ACL, don't define it in your modules adminhtml.xml.
The redirect to dashboard if you enter the URL manually probably comes from a missing/wrong key parameter that prevents ...
The error message is pretty clear about it:
Controller file was loaded but class does not exist
So the controller file has been loaded but the class name is wrong. Class name and file name in your question seem to match, but I noticed that TransationController probably should read TransactionController ("C" is missing).
Double check that file name and ...
I may be wrong here, but I think you have an other class that extends \Webkul\Grid\Controller\Adminhtml\Grid\Index.
And this class has as dependency an instance of the object manager.
Something like this:
class YourClassHere extends \Webkul\Grid\Controller\Adminhtml\Grid\Index
public function __construct(
I'm pretty sure it's because your URL is not properly generated.
Let's take the following example:
Here is how an URL should be generated and here is how you must replace the values:
adminRouteFrontName : it is the value declared in your adminhtml/routes.xml so I'm not sure what you put there in ...
You can read directly from config file such as app/etc/local.xml with:
Thus you can use the following:
However, instead of doing this I reckon you should use the helper that lets you generate admin URLs:
As Magento compile the classes and put them in var/generation folder, So it will always be a better practice to delete var/generation and var/cache folder, whenever you created a new class or change any parameters of constructor of any class.
If you don't want to delete whole folder then try to delete files from the same class path from where you are ...
So as far as I understand it you will need to update your module's config xml to also include the adminhtml dependency. To do this you should include the following in your Bye_World config.
The reason for this is....
In your block create
protected $_template = 'Company_Module::labelposition.phtml';
now, make labelposition.phtml and add your html field with attribute data-form-part="formname".
Here the formname must be name of your uiform like <uiComponent name="product_form"/>.
<input type="text" data-form-part="product_form" name="test" value="Hello ...
For all actions of a single controller class, you can override the preDispatch or postDispatch methods:
class YourController extends Mage_Adminhtml_Controller_Action
public function preDispatch()
// put logic before controller actions here
public function postDispatch()
// put logic ...
Double check to make sure all your files, folders and namespace are correct.
Did you include the following files:
Using the instruction you provide, I have recreated your module and it work find see demo https://github.com/magepal/stackexchange/tree/develop/102629
After do some ...
I just want to add that Your Question and Your answer both are working for me :).
I was searching for a simple method for redirection and accidentally I found that old method (of Mage 1) is still supported on Mage 2, I used the following code to redirect from my custom controller to product grid and it worked :)
Folder structure for following controller will be app/code/Test/Priya/Controller/Adminhtml/Priya in side that folder Index.php
class Index extends \Magento\Backend\App\...
It doesn't work because you are not stopping the current request. You need the following code too:
/** @var $controller Mage_Core_Controller_Varien_Action */
$controller = $observer->getData('controller_action');
To do the following in Magento 2, you must do the following in your execute method:
public function execute()
/* Do your controller action stuff here */
$resultRedirect = $this->resultRedirectFactory->create();
You don't need ...
It is a core Hack
Some one directly edited core file of Magento app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php. As the error indicates, go to the line 139 in that file and you can find PHP error (most probably some syntax error) there.
I recommend you to replace that file with original file. DO NOT EDIT THE CORE FILE DIRECTLY. Here is the ...
You can either move you controller file location or update you config.xml
Method 1 : Move your controller file from
Or Method 2 : change your config.xml and update your class definition
Should be as simple as adding extra parts to the action node.
Check out how the downloads part of the admin section works.
Here the controller is Mage_Adminhtml_Report_ProductController and the action is downloadsAction
You have to use the execute() method inside the controller. Each controller file has a single execute method. This execute method is responsible for returning a “result” object (i.e. an object that implements the Magento\Framework\Controller\ResultInterface interface).
See the code below :
I have never seen an official answer from a Magento engineer on the matter, but to me it always appeared that this feature is to be used when you want users to be able to link to a page from outside a secure session, as otherwise clicking on a link referencing a secure admin URL will only redirect you to the dashboard after prompting you to log in.
I always ...
In your config.xml
Problem is this line
When attempting to access modules/functionality in the backend (Adminhtml), Magento checks for the presence of the secret Form Keys, and if/when someone does attempt to access an action and doesn't supply a valid FormKey and/or supplies an Invalid FormKey - the Adminhtml AbstractAction (Magento\Backend\App\AbstractAction) will route the user Admin UIX ...
You can pass param like this :
$params = array('myname' => 'Nuno Sousa');
$resultRedirect->setPath('customer/index/new', ['params' => $params]);
You can retrive using this :