1

I'm working on creating iframe in magento2.

Content of this iframe should be a custom form, which exists in one of templates.

I made following:

<iframe src="<?php echo $this->getUrl('module/iframe/show') ?>" frameborder="0" style="height:75px;"></iframe>

It means that my controller module/iframe/show should return me a content for this form, but I don't know what exactly should return/render/output my controller. Now I can receive only full rendered page in this iframe. It means that probably block side is working well and i need only proper controller code

0

I have found an answer in default magento modules.

Some variables (block_name, form_id) were replaced with strings to clearly understand the idea.

    $this->getResponse()->setBody(
        $this->_view->getLayout()->createBlock(
            'Vendor\Module\Block\Adminhtml\Iframe\Show'
        )->setFormId(
            'form_id'
        )->setIsAjax(
            true
        )->toHtml()
    );

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.