2

I have an admin custom module in which there are three tabs present. First tab is use to collect basic informations of the module and second one is used for avanced information collection.

I want some of the content portions render with a template file and rest of the content render with the tab file itself in my second tab. Here is my second tab file

<?php
class Electronicsstore_News_Block_Adminhtml_News_Edit_Tab_Advance extends Mage_Adminhtml_Block_Widget_Form
{
    public function __construct()
  {                  

        $this->setTemplate('news/calendar/calendar.phtml');//use to render calander field   
        parent::__construct();                    
  }

  protected function _prepareForm()
  {
    $news = new Varien_Data_Form();
    $this->setForm($news);
    $fieldset = $news->addFieldset('news_advance',  array('legend'=>Mage::helper('news')->__('Advanced Settings')));


   //use to add date; need to add start and final days in this module
    $fieldset->addField('news_stime', 'time', array(
          'label'     => Mage::helper('news')->__('Start Date'),
          'class'     => 'required-entry',
          'required'  => true,
          'name'      => 'title',
          'onclick' => "",
          'onchange' => "",
          'value'  => '12,04,15',
          'disabled' => false,
          'readonly' => false,
          'after_element_html' => '<small>Comments</small>',
          'tabindex' => 1
    ));
    $fieldset->addField('news_ltime', 'time', array(
          'label'     => Mage::helper('news')->__('End Date'),
          'class'     => 'required-entry',
          'required'  => true,
          'name'      => 'title',
          'onclick' => "",
          'onchange' => "",
          'value'  => '12,04,15',
          'disabled' => false,
          'readonly' => false,
          'after_element_html' => '<small>Comments</small>',
          'tabindex' => 1
    ));
}
}

so I want render the calendar template first and then it should followed by those time fields which I have set through the method _prepareform() in my second tab's content section. Currently it is not working together. I didn't get the template file output in my tab. Is it possible in magento? Please enlighten me with good ideas. Thanks in advance

2

Change this method:

public function __construct()
{                   

    $this->setTemplate('news/calendar/calendar.phtml');//use to render calander field   
    parent::__construct();                    
 }

to

protected function _construct() //only one underscore in front
{                  
    parent::_construct(); //only one underscore
    $this->setTemplate('news/calendar/calendar.phtml');//use to render calander field   

}
7
  • Thanks for youranswer. Unforunately it is asked one year back and I dont have that module with me. When I get time, I will try to recreate above situation and then test your code. :-) – Rajeev K Tomy Feb 17 '15 at 8:20
  • @RKT-JoinMageStackDay2015. I'm sure it works :). It didn't work for you because the parent::__construct() method calls _construct method that sets the default template. Calling setTemplate after the _construct method does it's magic should solve your problem. – Marius Feb 17 '15 at 8:22
  • thanks. Then I will check it out the above logic flow and confirm it :-). Only one question. _construct is public or protected method ? – Rajeev K Tomy Feb 17 '15 at 8:25
  • and i also read somewhere that _construct function do not require a parent call. But I cant confirm that point – Rajeev K Tomy Feb 17 '15 at 8:27
  • right. It should be protected. I will change the answer. – Marius Feb 17 '15 at 8:29

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.