4

我正在使用 Magento v1.7.0.2 并尝试在注册表单上添加移动字段。我已经修改了代码(参见下面的代码)。但是,注册表单上仍未显示“移动”字段。

有没有人可以帮助我?提前致谢!

app\etc\modules\Mydons_Customer.xml

<config>
    <modules>
        <Mydons_Customer>
        <codePool>local</codePool>
        <active>true</active>
        </Mydons_Customer>
    </modules>
</config> 

app\code\local\Mydons\Customer\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mydons_Customer>
            <version>1.7.0.0</version>
        </Mydons_Customer>
    </modules>
    <global>
        <fieldsets>
            <customer_account>
                <mobile><create>1</create><update>1</update></mobile>
            </customer_account>
        </fieldsets>
        <models>
            <Mydons_Customer>
                <class>Mydons_Customer_Model</class>
            </Mydons_Customer>
        </models>
        <helpers>
            <Mydons_Customer>
                <class>Mydons_Customer_Helper</class>
            </Mydons_Customer>
        </helpers>
        <resources>
            <customerattribute_setup>
                <setup>
                    <module>Mydons_Customer</module>
                    <class>Mydons_Customer_Model_Entity_Setup</class>
                </setup>
            </customerattribute_setup>
        </resources>
    </global>
</config> 

app\code\local\Mydons\Customer\Model\Entity\Setup.php

class Mydons_Customer_Model_Entity_Setup extends Mage_Customer_Model_Entity_Setup
{
    public function getDefaultEntities(){

        return array(

                'mobile'=>array(
                        'type'=> 'static',
                        'label'=> 'Mobile',
                        'visiable' => true,
                        'required' => true,
                        'sort_order' => 80,
                )
        );
    }
} 

app\code\local\Mydons\Customer\sql\customerattribute_setup\mysql4-install-0.1.0.php

   $installer = $this;

    $installer->startSetup();


    $installer->addAttribute('customer', 'mobile', array(
        'label' => 'Mobile',
        'visible' => 1,
        'required' => 1,
        'position' => 1,
        'sort_order' => 80,        
    ));


    $installer->endSetup();

    $customer = Mage::getModel('customer/attribute')->loadByCode('customer', 'mobile');
    $forms= array('customer_account_edit', 'customer_account_create', 'adminhtml_customer', 'checkout_register');
    $customer->setData('used_in_forms', $forms);
    $customer->save(); 
4

1 回答 1

2

您需要修改相应的模板,在注册表单中添加您想要的字段。
在这种情况下,customer/form/register.phtml并且persistent/customer/form/register.phtml

于 2012-07-16T09:05:34.300 回答