2

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.

asked May 28, 2016 at 6:04
4
  • have you specified that block in layout.xml ? Commented Jan 7, 2017 at 7:24
  • Why i should add it inside layout.xml ??...I was trying to add it from block. However i managed to do it. Thanks. Commented Jan 7, 2017 at 8:21
  • @KingshukDeb, how did you add a custom template file for the admin form? Commented Jan 26, 2017 at 0:48
  • 1
    @KingshukDeb $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>') Commented Jan 26, 2017 at 2:11

1 Answer 1

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>';
 }
answered Jan 26, 2017 at 2:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.