首页 文章

在magento中的自定义模块中的编辑表单上调用特定选项卡

提问于
浏览
0

我在magento中创建了一个自定义模块 . 当我单击网格时,它会移动到编辑表单,在那里我可以看到三个选项卡,如tab1,tab2,tab3 . 选择默认tab1 . 现在我想在网格上添加一个链接点击该链接浏览器将用户重定向到tab3 . 我该怎么做 . 我的标签代码如下:

protected function _beforeToHtml()
  {
      $this->addTab('form_section', array(
          'label'     => Mage::helper('mymodule')->__('Information'),
          'title'     => Mage::helper('mymodule')->__('Information'),
          'content'   => $this->getLayout()->createBlock('mymodule/adminhtml_mymodule_edit_tab_form')->toHtml(),
      ));

     $this->addTab('form_section1', array(
          'label'     => Mage::helper('mymodule')->__(' Management'),
          'title'     => Mage::helper('mymodule')->__('Management'),
          'content'   => $this->getLayout()->createBlock('mymodule/adminhtml_mymodule_edit_tab_managment')->toHtml(),
      ));
          $this->addTab('form_section2', array(
          'label'     => Mage::helper('mymodule')->__('Results'),
          'title'     => Mage::helper('mymodule')->__('Results'),
          'content'   => $this->getLayout()->createBlock('mymodule/adminhtml_mymodule_edit_tab_result')->toHtml(),
      ));


      return parent::_beforeToHtml();
  }

我的链接代码就像网格列表页面上的那个 . <a class="viewit" href="http://localhost/project/index.php/mymodule/adminhtml_mymodule/view/id/4/key/83063e416ef7f9cfb7825d01e4519293/">View</a> . 我的控制器功能如下:

public function viewAction()
    {
     $this->loadLayout();
       $block = $this->getLayout()->createBlock('mymodule/adminhtml_mymodule_edit_tab_result');
      //  $this->_addContent($this->getLayout()->createBlock('mymodule/adminhtml_mymodule_edit_tab_result'))
            //->_addLeft($this->getLayout()->createBlock('mymodule/adminhtml_mymodule_edit_tabs'));
       $this->getLayout()->getBlock('content')->append($block);  
       $this->renderLayout();
}

1 回答

  • 3

    Mage_Adminhtml_Block_Widget_Tabs::addTab处的代码表明标签具有属性 active . 尝试将其添加到您的 addTab 电话:

    $this->addTab('form_section2', array(
              'label'     => Mage::helper('mymodule')->__('Results'),
              'title'     => Mage::helper('mymodule')->__('Results'),
              'content'   => $this->getLayout()->createBlock('mymodule/adminhtml_mymodule_edit_tab_result')->toHtml(),
              'active'    => true
          ));
    

    或者,您可以将参数 activeTab 设置为'form_section2'(活动选项卡的名称)的Grid的行URL扩展,并将以下代码添加到 Tabs 块类的 _beforeToHtml 函数中:

    $param = Mage::app()->getRequest()->get('activeTab');
            if (array_key_exists($param, $this->_tabs)) {
                $this->_tabs[$param]->setActive();
            }
    

相关问题