Magento自定义客户地址属性未保存

Magento自定义客户地址属性未保存,magento,Magento,我正在尝试将属性mobile添加到customer\u address实体。当我从前端创建用户时,Magento不会保存此属性值,但当我从管理员创建用户时,它会起作用 下面是代码片段 $installer->addAttribute('customer_address','trading2_mobile',array( 'type' => 'varchar', 'label' => 'Mobile 2',

我正在尝试将属性
mobile
添加到
customer\u address
实体。当我从前端创建用户时,Magento不会保存此属性值,但当我从管理员创建用户时,它会起作用

下面是代码片段

$installer->addAttribute('customer_address','trading2_mobile',array(
    'type'               => 'varchar',
    'label'              => 'Mobile 2',
    'input'              => 'text',
    'global' => 1,
    'visible' => 1,
    'required' => 0,
    'visible_on_front' => 1,
));

$trading2_mobile = Mage::getSingleton('eav/config')->getAttribute('customer_address', 'trading2_mobile');
$trading2_mobile->setData('used_in_forms',array('customer_register_address','customer_address_edit','adminhtml_customer_address'))->save();
前端代码

<div class="field">
  <label for="mobile2" class="required"><em>*</em><?php echo $this->__('Mobile 2') ?></label>
  <div class="input-box">
  <input type="text" name="mobile2" id="mobile2" value="<?php echo $this->htmlEscape($this->getFormData()->getTrading2Mobile()) ?>" title="<?php echo $this->__('Mobile 2') ?>" class="input-text required-entry" />
</div>
                    </div>

*
输入字段的名称和id(用于JS验证)属性应为“trading2_mobile”:

<input type="text" name="trading2_mobile" id="trading2_mobile" value="<?php echo $this->htmlEscape($this->getFormData()->getTrading2Mobile()) ?>" title="<?php echo $this->__('Mobile 2') ?>" class="input-text required-entry" />