0

I want to get parameters from my page to the second. My values are submitted in the first page, but I can't achieve to get data on my second page (where I want to display theses data). I'm trying this from one controller to another.

Here's history.php (first controller)

public function execute()
    {

        if ('POST' == $this->getRequest()->getMethod()) {

            $detailCommande = $this->getRequest()->getPost('detailCommande');
//            var_dump($detailCommande);

            if ($detailCommande != '') {
                $this->_redirect('recapitulatif/order/recapitulatif', array('_secured' => true, 'detailCommande' => $detailCommande));
            }

        }

        /** @var \Magento\Framework\View\Result\Page $resultPage */
        $resultPage = $this->resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->set(__('My Orders'));

        $block = $resultPage->getLayout()->getBlock('customer.account.link.back');
        if ($block) {
            $block->setRefererUrl($this->_redirect->getRefererUrl());
        }
        return $resultPage;
    }

The second controller (where I want to display)

public function execute() {

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

echo "<pre>";
print_r($post);
exit;

$this->_view->loadLayout();
$this->_view->renderLayout();
}

I have 2 more questions, is that possible pass an array as data in magento (data = my $_POST values) ? and is it possible to hide parameters in the url during a post request ?

Thanks !

0

I think you cant create a POST request from a redirect, the thing you can do is repeat the request to another url

You can try passing data with query string

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.