2012-07-23 123 views
0

我是一个magento的新手。我已经创建了一个自定义模块,它应该将自定义字段添加到客户注册页面。我已成功添加一个自定义字段给客户,在编辑客户或添加新客户时,我可以在管理员/客户中看到该字段。我怎样才能让它也显示在注册页面上?如何在magento的注册页面显示自定义字段?

这里是我的模块的安装文件:

mysql4安装-0.1.0.php

<?php 
$installer = $this; 
$installer->startSetup(); 

$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); 

$entityTypeId  = $setup->getEntityTypeId('customer'); 
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId); 
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId); 

$setup->addAttribute('customer', 'resale', array(
    'input'   => 'text', 
    'type'   => 'varchar', 
    'label'   => 'Resale number', 
    'visible'  => 1, 
    'required'  => 1, 
    'user_defined' => 1, 
)); 

$setup->addAttributeToGroup(
$entityTypeId, 
$attributeSetId, 
$attributeGroupId, 
'resale', 
'999' //sort_order 
); 

$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'resale'); 
$oAttribute->setData('used_in_forms', array('adminhtml_customer','customer_account_create')); 
$oAttribute->save(); 

$installer->endSetup(); 

谢谢。

回答

1

您应该添加代码register.html象下面这样:

<div class="field"> 
    <label for="my_attribute" class="required"><em>*</em><?php echo $this->__('My Attribute') ?></label> 
    <div class="input-box"> 
    <input type="text" name="my_attribute" id="my_attribute" value="<?php echo $this->htmlEscape($this->getFormData()->getMyAttribute()) ?>" title="<?php echo $this->__('My Attribute') ?>" class="input-text required-entry" /> 
    </div> 
</div> 
+0

谢谢你,它的工作! – Joonas 2012-07-24 02:32:12

相关问题