What i have tried is the following.
I have a class which extends Mage_Adminhtml_Block_Widget_Form. Inside that i have the _prepareLayout function. Now i have set a block inside that function like this.
echo $this->getLayout()->createBlock('adminhtml/template')->setTemplate('path/tothefile.phtml')->toHtml();
Its working. But the issue is i have a javascript code inside this .phtml file and its running twice.
May be because of the core/text_list block type of widget instance or for the toHtml() . Do you guys have any idea whats wrong.
1 Answer 1
Add __toHtml() method in form container block.
protected function _toHtml() {
$tabsContainer = $this->getLayout()->createBlock('core/text', 'example-block')->setText('<div id="messages"><ul class="messages"><li class="error-msg"><ul><li><span>CreateBlock.</span></li></ul></li></ul></div>');
return parent::_toHtml() .
$tabsContainer->toHtml() .
'<div data id="tabs_container"></div>';
}
layout.xml?$this->getLayout()->createBlock('core/text', 'example-block')->setText('<div id="messages"><ul class="messages"><li class="error-msg"><ul><li><span>CreateBlock.</span></li></ul></li></ul></div>')