I created my own admin route. This is it's controller:

Route controller


class Mediabase extends \Magento\Sales\Controller\Adminhtml\Order
    public function execute()

        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $urlInterface = $objectManager->get(\Magento\Backend\Model\UrlInterface::class);
        $mediabaseUrl = $urlInterface->getUrl("uo_mediabase/order/mediabase");

        $currentUrl = $urlInterface->getCurrentUrl();

This is the form which is calling the route

<div class="admin__page-section order-view-billing-shipping">
    <div class="admin__page-section-title">
        <span class="title">Mediabase</span>

    <div class="admin__page-section-item-title">
        <span class="title">Bestellnummer</span>

    <div class="admin__page-section-item-content">
        Mediabase-Bestellnummer: <?php echo $block->getMediabaseNumber(); ?>
    <form id="mediabase_edit_form" action="<?= $this->getFormUrl() ?>" method="post">
        <input type="text" name="bestellnr"><br/>
        <input class="action-default" type="submit" value="Speichern">

So when the route is called I want to get the



However my form doesn't seem to send POST data.

Do you know how I can achieve that?


  • If you put exit on controller, does it work when click submit? – Sukumar Gorai Jul 16 '18 at 12:51

First check your controller is being called on form submit or not if it's being called then follow below method

If you want to get post data from controller, $post = $this->getRequest()->getPostValue();

Here your full code,

Also You have to declare storemanager object inside __construct() function of your php file instead of use dirctly objectmanager.

I have updated your code as below,

class Index extends \Magento\Framework\App\Action\Action

     * @var \Magento\Framework\App\Cache\TypeListInterface
    protected $_cacheTypeList;

     * @var \Magento\Framework\App\Cache\StateInterface
    protected $_cacheState;

     * @var \Magento\Framework\App\Cache\Frontend\Pool
    protected $_cacheFrontendPool;

     * @var \Magento\Framework\View\Result\PageFactory
    protected $resultPageFactory;

     * @param Action\Context $context
     * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
     * @param \Magento\Framework\App\Cache\StateInterface $cacheState
     * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool
     * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
    public function __construct(
       \Magento\Framework\App\Action\Context $context,
       \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
       \Magento\Framework\App\Cache\StateInterface $cacheState,
       \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool,
       \Magento\Framework\View\Result\PageFactory $resultPageFactory,
       \Magento\Store\Model\StoreManagerInterface $storeManager
        $this->_cacheTypeList = $cacheTypeList;
        $this->_cacheState = $cacheState;
        $this->_cacheFrontendPool = $cacheFrontendPool;
        $this->resultPageFactory = $resultPageFactory;
        $this->storeManager = $storeManager;

     * Flush cache storage
    public function execute()
        $currentStore = $this->storeManager->getStore();
        $baseUrl = $currentStore->getBaseUrl();

        $post = $this->getRequest()->getPostValue();

        echo "<pre>";


Also, you can check here:



You can use the following code to get post or get values from form to controller action:

Below code will return all the parameters either post or get:

$params = $this->getRequest()->getParams();

If you want only one variable value then you can use the following code:

$variable_name = $this->getRequest()->getParam('variable_name');

In your case you can use the following code to get bestellnr value:

$bestellnr = $this->getRequest()->getParam('bestellnr');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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