0

I have added form in the backend. At the end of the form I need to include a phtml content using it's block. How can we include phtml file after the form content?

3 Answers 3

1

You can try following code at the end of your phtml form

echo $this->getLayout()->createBlock("Path\to\Block")->setTemplate("Vendor_Module::your_template.phtml")->toHtml()
2
  • It comes in the top of the contents...not coming inside the form tab
    – SIBHI S
    Aug 29, 2017 at 11:50
  • Please post your corresponding layout xml Aug 29, 2017 at 12:11
0

Add the following function to your block

public function getFormHtml()
{
    $html = parent::getFormHtml();  
    $html .= $this->setTemplate('Vendor_Module::your_template.phtml')->toHtml(); 
    return $html;
}

Don't forget to create the phmtl at Vendor/Module/view/adminhtml/templates/your_template.phtml

0

Add in the layout page for customer_index_edit.xml (add in xml file for edit)

<referenceContainer name="content"> <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View" name="customer_edit_tab_view" template="tab/view.phtml"> <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo" name="personal_info" template="tab/view/personal_info.phtml"/> </block> <referenceContainer>

In tab/view.phtml you call function echo $block->getChildHtml();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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