Magento-将新选项卡添加到管理客户编辑&;包含来自模型的表单
我试图在Magento admin的Customer Edit页面中添加一个新选项卡,该选项卡上有一个使用模型加载和保存数据的表单 我的标签可以这样工作(但我很确定这种方式是非常糟糕的做法): Sulman/Tabtest/Block/Adminhtml/Customer/Edit/Tab/Action.phpMagento-将新选项卡添加到管理客户编辑&;包含来自模型的表单,magento,Magento,我试图在Magento admin的Customer Edit页面中添加一个新选项卡,该选项卡上有一个使用模型加载和保存数据的表单 我的标签可以这样工作(但我很确定这种方式是非常糟糕的做法): Sulman/Tabtest/Block/Adminhtml/Customer/Edit/Tab/Action.php public function __construct() { $this->setTemplate('tabtest/action.phtml')
public function __construct()
{
$this->setTemplate('tabtest/action.phtml');
}
public function getCustomtabInfo(){
$customer = Mage::registry('current_customer');
$customtab='My test tab';
return $customtab;
}
/**
* Return Tab label
*
* @return string
*/
public function getTabLabel()
{
return $this->__('Sulman Test Tab');
}
/**
* Return Tab title
*
* @return string
*/
public function getTabTitle()
{
return $this->__('Sulman Test Tab Title');
}
/**
* Can show tab in tabs
*
* @return boolean
*/
public function canShowTab()
{
$customer = Mage::registry('current_customer');
return (bool)$customer->getId();
}
/**
* Tab is hidden
*
* @return boolean
*/
public function isHidden()
{
return false;
}
/**
* Defines after which tab, this tab should be rendered
*
* @return string
*/
public function getAfter()
{
return 'tags';
}
}
然后,我的etc/config.xml如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Sulman_Tabtest>
<version>0.0.1</version>
</Sulman_Tabtest>
</modules>
<adminhtml>
<layout>
<updates>
<tabtest>
<file>tabtest.xml</file>
</tabtest>
</updates>
</layout>
</adminhtml>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<sulman_tabtest before="Mage_Adminhtml">Sulman_Tabtest_Adminhtml</sulman_tabtest>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<global>
<blocks>
<tabtest>
<class>Sulman_Tabtest_Block</class>
</tabtest>
</blocks>
</global>
</config>
0.0.1
tabtest.xml
Sulman_Tabtest_Adminhtml
苏尔曼塔布测试块
最后,我的tabtest/action.phtml如下所示(右图…):
最大订购量:您可以通过应用下面文章中给出的代码来尝试
谢谢,但这几乎和我的一样(我也用过),我确信实现这一点的方法是完全错误的。
<?php
$customer = Mage::registry('current_customer');
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
$sql = "SELECT * FROM mytable WHERE entity_id = '".$customer->getId()."'";
$results = $read->fetchAll($sql);
?>
<div id="customer_info_tabs_customer_edit_tab_action_content">
<div class="entry-edit">
<div class="entry-edit-head">
<h4 class="icon-head head-edit-form fieldset-legend">My title</h4>
</div>
<div id="group_fields4" class="fieldset fieldset-wide">
<div class="hor-scroll">
<h3>My title</h3>
<div>
<form action="<?php echo $this->getUrl('adminhtml/tabtest/update/', array('customer_id' => $customer_id)); ?>;" method="get">
<?php foreach($results as $result):?>
<p>
<strong><?php echo $result['email']?></strong><br/>
Max Order Amount: <input type="text" name="max_order_amount" value="<?php echo $result['max_order_amount']?>"><br/>
</p>
<?php endforeach; ?>
<input type="submit" value="Post This Form"/>
</form>
</div>
</div>
</div>
</div>
</div>