I am tring to call block from the controller action but its not working and throwing me an error as

Exception #0 (OutOfBoundsException): No element found with ID 'left'.



Can you please tell me how can i achieve above things?

  • From which controller, Its backend controller? – Sohel Rana Jul 14 '16 at 6:44
  • Yes, Its a backend controller. – Sanjay Jethva Jul 14 '16 at 11:17

First of all, you should not add blocks from the controller. Use the layout file for that.
But if you do, you need to call $this->_view->loadLayout() prior to adding your blocks.
and make sure your layout file has the main tag looking like this:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

layout="admin-2columns-left" ensures you that the left column exists.

| improve this answer | |

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.