Craft CMS Asked on March 1, 2021
I’m building out a Craft 3 plugin and can’t see who to pass variables with redirection from a controller.
For example, I have a controller that I want to pass back to the defined redirect value along with a variable, eg:
return $this->redirectToPostedUrl( ['order' => $order ] );
However, trying to access the order variable within my template is returning empty. The order object definitely exists before the redirection as it can be accessed from within my controller.
Any suggestions appreciated – I’m sure am overlooking something quite straightforward!
Try this:
Craft::$app->getUrlManager()->setRouteParams([
'variables' => ['order' => $order]
]);
Answered by Nikolay Bronskiy on March 1, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP